Home > Web Front-end > HTML Tutorial > 通过定位实现的div块网页中固定效果_html/css_WEB-ITnose

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

WBOY
Release: 2016-06-24 11:29:40
Original
1215 people have browsed it

通过定位实现的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>
Copy after login

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

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

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

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template