通过使用jQuery,我为我构建的一个游戏创建了一个3按钮警报,以增加它的难度。
当我开始为警报编写脚本时,覆盖层工作得很好,但是现在由于某种原因,它没有覆盖对话框下面的水平条带。我不确定这是javascript还是CSS做的,但我需要保留这两种情况,因为这是完全覆盖。
jsFiddle示例:http://jsfiddle.net/spedwards/dJVF3/
CSS:
p {
text-align: center;
}
.no-close .ui-dialog-titlebar-close {
display: none;
}
.ui-dialog-titlebar.ui-widget-header {
background: #104f96; /* Old browsers */
background: -moz-linear-gradient(top, #104f96 0%, #157dd3 45%, #54abee 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#104f96), color-stop(45%,#157dd3), color-stop(100%,#54abee)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #104f96 0%,#157dd3 45%,#54abee 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #104f96 0%,#157dd3 45%,#54abee 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #104f96 0%,#157dd3 45%,#54abee 100%); /* IE10+ */
background: linear-gradient(to bottom, #104f96 0%,#157dd3 45%,#54abee 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#104f96', endColorstr='#54abee',GradientType=0 ); /* IE6-9 */
}
div.ui-widget-content {
background: #74bbf2;
}
.ui-widget-content, .ui-dialog-titlebar.ui-widget-header {
border: 1px solid #fff;
}
.ui-state-default {
border: 1px solid #fff !important;
background: #539ff5 !important;
background: -moz-linear-gradient(top, #539ff5 0%, #78bef8 50%, #6cb7f8 51%, #add9fb 100%) !important;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#539ff5), color-stop(50%,#78bef8), color-stop(51%,#6cb7f8), color-stop(100%,#add9fb)) !important;
background: -webkit-linear-gradient(top, #539ff5 0%,#78bef8 50%,#6cb7f8 51%,#add9fb 100%) !important;
background: -o-linear-gradient(top, #539ff5 0%,#78bef8 50%,#6cb7f8 51%,#add9fb 100%) !important;
background: -ms-linear-gradient(top, #539ff5 0%,#78bef8 50%,#6cb7f8 51%,#add9fb 100%) !important;
background: linear-gradient(to bottom, #539ff5 0%,#78bef8 50%,#6cb7f8 51%,#add9fb 100%) !important;
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#539ff5', endColorstr='#add9fb',GradientType=0 ) !important;
}Javascript:
$(function () {
$('.diff').click(function (e) {
e.preventDefault();
$.ui.dialog.prototype._focusTabbable = function(){};
var dialog = $('<p>Select your difficulty</p>').dialog({
resizable: false,
closeOnEscape: false,
width: 350,
modal: true,
dialogClass: "no-close",
draggable: false,
title: 'Difficulty',
buttons: {
"Easy": function () {
easy();
dialog.dialog('destroy');
},
"Normal": function () {
normal();
dialog.dialog('destroy');
},
"Insane": function () {
insane();
dialog.dialog('destroy');
}
},
open: function(e, ui) {
$('button').blur();
}
});
});
});
function easy() {
alert('You selected Easy');
}
function normal() {
alert('You selected Normal');
}
function insane() {
alert('You selected Insane! Good luck!');
}谁能给我解释一下为什么覆盖不覆盖整个窗户。
发布于 2014-02-22 05:56:20
我不熟悉jquery,但是如果您通过开发人员工具检查Google上的覆盖层,就会看到jquery将一个白色背景图像应用于.ui-widget-overlay,该图像水平地重复:
.ui-widget-overlay {
background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x;
opacity: .3;
filter: Alpha(Opacity=30);
}因此,您可以通过如下重写background属性来修复这个问题:
.ui-widget-overlay {
background: #aaa !important;
}在线演示。
https://stackoverflow.com/questions/21950278
复制相似问题