Fixed固定位置的悬浮div层
2015-06-13 10:48
369 查看
固定位置的Js悬浮窗口,为了便于查看效果,测试时用随机函数产生一定的内容,与浮动窗口的控制无关,不想用可以去掉。代码内有注释。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>Fixed固定位置的悬浮div层丨电表控制器丨河北草坪</title> <style> * { font-size:12px; font-family:Verdana,宋体; } html, body { margin:0px; padding:0px; overflow:hidden; } .b { margin:0px; padding:0px; overflow:auto; } .line0 { line-height:20px; background-color:lightyellow; padding:0px 15px; } .line1 { line-height:18px; background-color:lightblue; padding:0px 10px; } .w { position:absolute; right:10px; bottom:10px; width:160px; height:240px; overflow:hidden; border:2px groove #281; cursor:default; -moz-user-select:none; } .t { line-height:20px; height:20px; width:160px; overflow:hidden; background-color:#27C; color:white; font-weight:bold; border-bottom:1px outset blue; text-align:center; } .winBody { height:218px; width:160px; overflow-x:hidden; overflow-y:auto; border-top:1px inset blue; padding:10px; text-indent:10px; background-color:white; } </style> </head> <body> <div class="w"> <div class="t">固定层</div> <div class="winBody">欢迎光临<br><br><br><br>www.sjzkeda.com</div> </div> </body> <hr> <script> //测试用,随机产生一定的内容 for(var i=0; i<400; i++)document.write("<div class=\"line"+(i%2)+"\">"+(new Array(20)).join((Math.random()*1000000).toString(36)+" ")+"<\/div>"); //代码如下: new function(w,b,c,d,o){ d=document;b=d.body;o=b.childNodes;c="className"; b.appendChild(w=d.createElement("div"))[c]= "b"; for(var i=0; i<o.length-1; i++)if(o[i][c]!="w")w.appendChild(o[i]),i--; (window.onresize = function(){ w.style.width = d.documentElement.clientWidth + "px"; w.style.height = d.documentElement.clientHeight + "px"; })(); } </script> </html>
相关文章推荐
- 《Pro Ogre 3D Programming》读书笔记 之 第十一章 动态阴影
- 由先序序列/后序序列和中序序列构造二叉树
- IOS开发—视图控制器左边缘右滑pop出栈
- cocos2d-x3.2中将XCode发展project转移到VS2010可能会发生错误
- Hibernate中Criteria的完整用法
- 那些在学习iOS开发前就应该知道的事
- 常用的php ADODB使用方法集锦
- 又安上了好多otherthings.......
- SOA面向服务架构的一些思考
- Javascript中call的使用
- [leetcode] House Robber II
- Java-核心技术总结-第3章
- VM虚拟机中的Ubuntu设置固定IP上网图文教程
- eclipse打开文件所在的本地文件夹
- 初识Struts2框架
- Android获取屏幕分辨率及DisplayMetrics简介
- Java 工厂模式
- Hibernate SQLQuery 原生SQL 查询及返回结果集处理-1
- 模拟面试100问
- phpPHP创建创建jpg格式图片以及压缩图片(转)