Js实现网页右下角固定位置的悬浮窗口代码,为了便于查看效果,测试时用随机函数产生一定的内容,与浮动窗口的控制无关,不想用可以去掉。代码内有注释。 示例: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /> <html xmlns="http://www.w3.org/1999/xhtml"><br /> <head><br /> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><br /> <title>Fixed固定位置的悬浮</title><br /> <style><br /> * { font-size:12px; font-family:Verdana,宋体; }<br /> html, body { margin:0px; padding:0px; overflow:hidden; }<br /> .b { margin:0px; padding:0px; overflow:auto; }<br /> .line0 { line-height:20px; background-color:lightyellow; padding:0px 15px; }<br /> .line1 { line-height:18px; background-color:lightblue; padding:0px 10px; }<br /> .w { position:absolute; right:10px; bottom:10px; width:160px; height:240px; overflow:hidden; border:2px groove #281; cursor:default; -moz-user-select:none; }<br /> .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; }<br /> .winBody { height:218px; width:160px; overflow-x:hidden; overflow-y:auto; border-top:1px inset blue; padding:10px; text-indent:10px; background-color:white; }<br /> </style><br /> </head><br /> <body><br /> <div class="w"><br /> <div class="t">Demo Win - Fixed</div><br /> <div class="winBody">Hello world</div><br /> </div><br /> </body><br /> <script><br /> //测试用,随机产生一定的内容<br /> for(var i=0; i<400; i++)document.write("<div class=\"line"+(i%2)+"\">"+(new Array(20)).join((Math.random()*1000000).toString(36)+" ")+"<\/div>");<br /> //代码如下:<br /> new function(w,b,c,d,o){<br /> d=document;b=d.body;o=b.childNodes;c="className";<br /> b.appendChild(w=d.createElement("div"))[c]= "b";<br /> for(var i=0; i<o.length-1; i++)if(o[i][c]!="w")w.appendChild(o[i]),i--;<br /> (window.onresize = function(){<br /> w.style.width = d.documentElement.clientWidth + "px";<br /> w.style.height = d.documentElement.clientHeight + "px";<br /> })();<br /> }<br /> </script><br /> </html><br /><center>如不能显示效果,请按Ctrl+F5刷新本页,更多网页代码:<a href='http://www.veryhuo.com/' target='_blank'>http://www.veryhuo.com/</a></center>提示:可修改后代码再运行! 文章导航 点击按钮Alert弹出遮罩层效果的提示框代码Css 相对定位网页框架代码,滚动时不闪烁