日期:2014-05-17  浏览次数:20845 次

一个在浏览器底部固定浮动的DIV如何实现(只用css)?
就在已有的页面用js动态插入一段html代码,不改变其它原有标签的属性
<div style="怎么写?">我要固定浮动在底部</div> //只靠这段代码,改变style

该如何实现?

------解决方案--------------------
HTML code

<!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>testing</title>
<style type="text/css">
.shape{width:200px; height: 140px; position:fixed!important; position:absolute; right:5px; bottom:5px!important; bottom:auto; top: expression(eval(document.compatMode && document.compatMode=='CSS1Compat') ? documentElement.scrollTop+(documentElement.clientHeight - this.clientHeight):document.body.scrollTop+(document.body.clientHeight - this.clientHeight));}
.shape .con{width:200px; height:100px; background: url(http://static.l99.com/skin/default/images/versus/pk_vote_record.gif) no-repeat;}
.shape .btn{width:200px; height:40px; background: url(http://static.l99.com/skin/default/images/versus/pk_vote_record.gif) no-repeat 0 -100px;}
.height{height:1300px;}
</style>
</head>
<body>
<div class="shape">
<div class="con"></div>
<div class="btn"></div>
</div>
<div class="height">
</div>
</body>
</html>

------解决方案--------------------
<div style="left:0; bottom:0; POSITION:absolute; width:100px; height:100px; z-index:100;">我要固定浮动在底部</div>

到底要底部哪个位置,自己改下left:***
------解决方案--------------------
#foot{position:fixed;_position:absolute;bottom:0px;_bottom:0px;_margin-top:expression(this.style.pixelHeight+document.documentElement.scrollTop)}


试下。
------解决方案--------------------
HTML code
<!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>testing</title>
<style type="text/css">
#foot{position:fixed;_position:absolute;bottom:0px;_bottom:0px;_margin-top:expression(this.style.pixelHeight+document.documentElement.scrollTop)}
</style>
</head>
<body style="height:5000px;">
<div id="foot">
我不在下面?
</div>
</body>
</html>

------解决方案--------------------
JScript code


document.getElementById("shows").style.top=(document.documentElement.scrollTop || document.body.scrollTop)+ieheight-5-showsHeight+"px";

------解决方案--------------------
探讨

我的意思是随便找个页面,粘贴上这段代码,这个div就可以固定浮动在页面最低端,
拖动滚动条浏览始终在最低端

------解决方案--------------------
<body> 
<div id="container"></div> 
<div id="bottom"></div> 
</body> 
html, body { 
 margin: 0; 
 padding: 0; 
 height: 100%; 
 width: 100%; 
 _overflow: hidden; 

#container { 
 _width: 100%; 
 _height: 100%; 
 _overflow-y: scroll; 

#bottom { 
 background-color: #0ff; 
 height: 30px; 
 width: 100%;