ホームページ > ウェブフロントエンド > jsチュートリアル > javascript_javascript スキルによって実装された固定位置フローティング ウィンドウの例

javascript_javascript スキルによって実装された固定位置フローティング ウィンドウの例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
リリース: 2016-05-16 16:01:45
オリジナル
7801 人が閲覧しました

この記事の例では、JavaScript によって実装された固定位置のフローティング ウィンドウについて説明します。皆さんの参考に共有してください。具体的な実装方法は以下の通りです。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

<!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>http://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 プログラミング設計に役立つことを願っています。

このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート