Web_CSS_DIV相对浏览器定位及其关闭;
2014-03-03 13:48
441 查看
功能: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'; //不显示; } }
相关文章推荐
- CSS实现相对浏览器窗口定位
- 实例演示div+css的绝对定位和相对定位布...
- absolute绝对定位(相对于整个html流)以及不为人知的(fixed)绝对定位(fixed相对于浏览器窗口=不动的div)
- 利用CSS实现DIV在浏览器中位置相对固定,而且IE6下滚动不闪
- 详解学习DIV+CSS之绝对定位和相对定位
- CSS+DIV:父DIV相对定位+子DIV绝对定位
- div+css绝对定位和相对定位
- DIV+CSS相对IE6 IE7和IE8浏览器行为区别及兼容性问题整理
- CSS+DIV里面相对定位和绝对定位的区别
- 浏览器兼容:Web标准化建站(DIV+CSS)必看的常见问题解决方法
- CSS+DIVweb排版的定义及常见的浏览器兼容问题
- DIV+CSS相对部分浏览器兼容问题的一些解决方案
- div+css 中相对定位于绝对定位的详解
- 实例演示div+css的绝对定位和相对定位
- CSS+jquery 实现滑动下拉框 DIV相对于浏览器固定位置
- CSS+DIV:父DIV相对定位+子DIV绝对定位
- 浏览器兼容:Web标准化建站(DIV+CSS)的常见问题解决方法
- CSS控制DIV绝对定位、相对定位的技巧
- CSS中的绝对定位与相对定位
- CSS:Table-cell属性的妙用让div也能享受table定位的好处