Heim  >  Artikel  >  Web-Frontend  >  通过定位实现的div块网页中固定效果_html/css_WEB-ITnose

通过定位实现的div块网页中固定效果_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:29:401155Durchsuche

通过定位实现的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/

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn