Web_CSS_DIV相对浏览器定位及其关闭;

功能:DIV相对浏览器定位及其关闭。

>html源码

<html>
	<head>
		<title>hello</title>
		<style tyle="text/css">
			html,body {
				width:100%;
				height:100%;
				margin:0px;
				padding:0px;
				overflow:hidden;	//溢出隐藏;解决IE8滚动条问题;
			}
		
			#Main {
				position:absolute;
				top:0px;
				left:0px;
				width:100%;
				height:100%;
				overflow:auto;	//能显示完所有内容;
				z-index:1;
			}
		
			.floatDiv {
				position:absolute;
				top:50px;
				right:30px;
				padding: 3 3 3 3;
				background:#ccc;
				text-align:right;
				z-index:2;
			}
			
			.close {
				background-color:#CC6600;
				cursor: pointer;
				color: #FFFFFF;
			}
		</style>
		<script type="text/javascript" src="hello.js"></script>
	</head>
	
	<body>
		<div id="Main">
			First,hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			hello,world!<br />
			last,hello,world!<br />
		</div>
		<div id="fDiv" class="floatDiv">
			<div><span id="closeBtn" class="close">关闭</span></div>
			<img src="img/sleep.jpg" width="200" height="150" />
		</div>
	</body>
</html>

>js源码

window.onload = initFn;

function initFn() {
	// 关闭按钮
	var closeBtn = document.getElementById("closeBtn");
	closeBtn.onclick = function(){
		// 浮动DIV
		var floatDiv = document.getElementById("fDiv");
		floatDiv.style.display	= 'none';		//不显示;
	}
	
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值