您的位置:首页 > Web前端 > JQuery

jquery 通过css 弹出悬浮框的办法

2014-01-21 13:54 344 查看
1是在body后面append一个div,div的position是absolute,位置大小是整个document的大小。这样就把页面全部变灰了。

2是把弹出的那个div显示出来,position也是用absolute。设置位置

js内容

var ShowBox = function(o, option) {
var docheight = $(document).height();
$("body").append("<div class='Box-background'></div>");
$(".Box-background").css({
"opacity" : "0.6",
"height" : docheight
});
var winHeight = document.documentElement.clientHeight;
var winWidth = document.documentElement.clientWidth;
$(o).css({
"top" : (200 + (winHeight - o.height()) / 2) + "px",
"left" : (winWidth - o.width()) / 2 + "px"
}).show();
};


ShowBox($(".nwd-float"));


html内容

<div class="Windows nwd-float">
<div class="nwd-closediv"><a href="javascript:" class="nwd-close"></a></div>
<div class="nwd-content">
<span id="takeSuccSpan"></span>
<a href="/xiangmu/"></a>
</div>
</div>


css内容

.Box-background {
background: none repeat scroll 0 0 #000000;
display: block;
left: 0;
position: absolute;
top: 0;
width: 100%;
z-index: 100;
}
.Windows {
color: #643B1B;
display: none;
left: 0;
position: absolute;
top: 0;
width: 503px;
z-index: 204;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: