js+css使DIV始终居于屏幕中间 左下 左上 右上 右下的代码集合
js+css使DIV始终居于屏幕中间 左下 左上 右上 右下的代码集合
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:

复制代码 代码如下:

<!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/

<!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>

<TITLE>随滚动条移动的层 </TITLE>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html" charset="gb2312">

</HEAD>

<style>

<>

</style>

<BODY>

<div id="Javascript.Div1" align="center">正中...</div>

<SCRIPT LANGUAGE="JavaScript">

function sc1(){

document.getElementById("Javascript.Div1").style.top=(document.documentElement.scrollTop+(document.documentElement.clientHeight-document.getElementById("Javascript.Div1").offsetHeight)/2)+"px";

document.getElementById("Javascript.Div1").style.left=(document.documentElement.scrollLeft+(document.documentElement.clientWidth-document.getElementById("Javascript.Div1").offsetWidth)/2)+"px";

}

</SCRIPT>

<div id="Javascript.Div2" align="center">左上...</div>

<SCRIPT LANGUAGE="JavaScript">

function sc2(){

document.getElementById("Javascript.Div2").style.top=(document.documentElement.scrollTop)+"px";

document.getElementById("Javascript.Div2").style.left=(document.documentElement.scrollLeft)+"px";

}

</SCRIPT>

<div id="Javascript.Div3" align="center">左下...</div>

<SCRIPT LANGUAGE="JavaScript">

function sc3(){

document.getElementById("Javascript.Div3").style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-document.getElementById("Javascript.Div3").offsetHeight)+"px";

document.getElementById("Javascript.Div3").style.left=(document.documentElement.scrollLeft)+"px";

}

</SCRIPT>

<div id="Javascript.Div4" align="center">右上...</div>

<SCRIPT LANGUAGE="JavaScript">

function sc4(){

document.getElementById("Javascript.Div4").style.top=(document.documentElement.scrollTop)+"px";

document.getElementById("Javascript.Div4").style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById("Javascript.Div4").offsetWidth)+"px";

}

</SCRIPT>

<div id="Javascript.Div5" align="center">右下...</div>

<SCRIPT LANGUAGE="JavaScript">

function sc5(){

document.getElementById("Javascript.Div5").style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-document.getElementById("Javascript.Div5").offsetHeight)+"px";

document.getElementById("Javascript.Div5").style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById("Javascript.Div5").offsetWidth)+"px";

}

</SCRIPT>

<SCRIPT LANGUAGE="JavaScript">

<>

</SCRIPT>

<div></div>

</BODY>

</HTML>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类