固定导航栏:
一条导航栏,无论页面怎么滚动,导航栏的位置始终固定在顶部。
实现:
其实很简单,在CSS里给导航栏所在的div设置四个属性,position设置为fixed,top和left设置为0px,然后把z-index的值设置成最高,即可实现。
css代码如下:
- /* FixTop. Create by Alvin Xing */
- *{
- margin: 0px;
- padding: 0px;
- }
- div{
- width: 800px;
- height: 30px;
- background-color: #c0c0c0;
- float: left
- }
- #header{
- position: fixed;
- top: 0px;
- left: 0px;
- z-index: 100;
- }
来源: http://www.phpxs.com/code/1005285/