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

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;
	}


猜你喜欢

转载自blog.csdn.net/u010653311/article/details/18603129