Fixed position floating window instance implemented by javascript

  • 2020-06-03 05:45:29
  • OfStack

An example of the javascript implementation of fixed position floating window is presented. Share to everybody for everybody reference. Specific implementation methods are as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Fixed Levitation in fixed position </title>
* { font-size:12px; font-family:Verdana, Song typeface ; }
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;
<div class="w">
<div class="t">Demo Win - Fixed</div>
<div class="winBody">Hello world</div>
// Test it, random generation 1 The content of the set 
for(var i=0; i<400; i++)document.write("<div class=\"line"+(i%2)+"\">"+(new Array(20)).join((Math.random()*1000000).toString(36)+" ")+"<\/div>");
// The code is as follows: 
new function(w,b,c,d,o){
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(){ = d.documentElement.clientWidth + "px"; = d.documentElement.clientHeight + "px";

Hopefully, this article has been helpful in your javascript programming.

Related articles: