0
我有一个简单的模式对话框打开这样的:面向较低层到关闭模式对话框
<div id="social" class="overlay">
<div class="inner">
<a class="close" href="#"><span class="icon-close"></span></a>
CONTENT
</div>
</div>
这里的CSS:
.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 100;
background: fade(@black, 75%);
display: none;
z-index: 999;
}
#social .inner {
margin: 0 auto;
z-index: 1000;
width: 380px;
}
这里是JS:
$(document).ready(function(){
$("#social").css("height", $(document).height());
$(".social").click(function(){
$("#social").fadeIn();
return false;
});
$(".close").click(function(){
$("#social").fadeOut();
return false;
});
});
当有人点击与类close
的链接时,模式框关闭。我想模态框也关闭时,有人点击模式框外的任何地方,所以覆盖层(z-index:999
)的任何地方。我不知道如何定位底层(z-index:999
)而不会影响顶层(z-index:1000
)。
我对jQuery不太了解,所以如果你能以新手的方式说出你的建议,那会很棒。谢谢! :)
为编辑@KilianStinson谢谢! – 2013-05-13 11:48:52
谢谢!但是,当我点击内容(实际的模式框)时,这也会关闭模式框。我只希望它在模式框外部即在背景上单击时关闭。 – 2013-05-13 12:14:42
啊,你的编辑使它工作。非常感谢! :) – 2013-05-13 12:19:42