javascript实现的固定位置悬浮窗口实例
更新时间:2015年04月30日 09:15:43 作者:休闲生活文化
这篇文章主要介绍了javascript实现的固定位置悬浮窗口,以一个完整实例形式详细分析了javascript实现固定位置悬浮窗口的相关技巧,非常具有实用价值,需要的朋友可以参考下
本文实例讲述了javascript实现的固定位置悬浮窗口。分享给大家供大家参考。具体实现方法如下:
<!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固定位置的悬浮</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">Demo Win - Fixed</div> <div class="winBody">Hello world</div> <div>https://www.jb51.net/</div> </div> </body> <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>
希望本文所述对大家的javascript程序设计有所帮助。
相关文章
JavaScript编程设计模式之观察者模式(Observer Pattern)实例详解
这篇文章主要介绍了JavaScript编程设计模式之观察者模式(Observer Pattern),简单说明了观察者模式的概念、原理并结合实例形式详细给出了观察者模式的相关实现与使用技巧,需要的朋友可以参考下2017-10-10关于BootStrap modal 在IOS9中不能弹出的解决方法(IOS 9 bootstrap modal ios
本文给大家介绍BootStrap modal 在IOS9中不能弹出的问题以及bootstrap datepicker 在bootstrap modal中不显示问题的解决方案,非常不错,需要的朋友参考下2016-12-12Selenium执行Javascript脚本参数及返回值过程详解
这篇文章主要介绍了Selenium执行Javascript脚本参数及返回值过程详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下2020-04-04
最新评论