日期:2014-05-19  浏览次数:20639 次

求一html特效
我想有做一个层.无论如何当要位于浏览器中间(当前见到区域).无论最少化.还是缩少.又或者拖动滚动条.那个层也会跟住浏览器居中的.

------解决方案--------------------
<!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> 随滚动条移动的层 - 51windows.Net </TITLE>
<META HTTP-EQUIV= "Content-Type " CONTENT= "text/html " charset= "gb2312 ">
<META NAME= "Author " CONTENT= "haiwa ">
<META NAME= "homepage " CONTENT= "www.51windows.net ">
</HEAD>
<style>
<!--
.div{
position: absolute;
border: 2px solid red;
background-color: #EFEFEF;
line-height:90px;
font-size:12px;
z-index:1000;
}
-->
</style>
<BODY>
<div id= "Javascript.Div1 " class= "div " style= "width: 240px; height:90px " 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 " class= "div " style= "width: 240px; height:90px " 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 " class= "div " style= "width: 240px; height:90px " 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 " class= "div " style= "width: 240px; height:90px " 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 " class= "div " style= "width: 240px; height:90px " align= "center "> 右下... </div>
<SCRIPT LANGUAGE= "JavaScript ">
function sc5(){
document.getElementById( "Javascript