透过定位实现的div块网页中固定效果

通过定位实现的div块网页中固定效果

通过定位实现的div块网页中固定效果:
本章节介绍一下如何让通过定位方式让一个div定位于网页的一个位置,无论是否拖动滚动条。
代码实例如下:

<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>蚂蚁部落</title>
<style type="text/css"> 
body{ 
  margin:0px auto;
  height:1000px;
} 
#fixedLayer{ 
  position:fixed; 
  left:40px; 
  top:10px; 
  width:100px; 
  line-height:30px; 
  background:#FC6; 
  border:1px solid #F90; 
} 
</style> 
</head> 
<body> 
<div id="fixedLayer">蚂蚁部落</div>  
</body> 
</html>

以上代码实现了我们的要求,这里是用过设置元素position:fixed,不过IE6不支持,不过本人感觉IE6还需要考虑吗。

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=13917

更多内容可以参阅:http://www.softwhy.com/divcss/