固定定位

2019-05-30  本文已影响0人  爱抽烟的臭屁虫

                        固定定位

固定定位

.box1{

width:200px;

height:200px;

background-color:red;

}

.box2{

width:200px;

height:200px;

background-color:yellow;

/*

当元素的position属性设置fixed时,则开启了元素的固定定位

固定定位也是一种绝对定位,它的大部分特点都和绝对定位一样

不同的是:

固定定位永远都会相对于浏览器窗口进行定位

固定定位会固定在浏览器窗口某个位置,不会随滚动条滚动

IE6不支持固定定位

*/

        position:fixed;

left:0px;

top:0px;

}

.box3{

width:200px;

height:200px;

background-color:yellowgreen;

}

<div style='...'></div>

<div class='box4' style='...'>

    <div cclass='box2'></div>

</div>

<div class='box3'></div>

代码实现:

固定定位 滚动滑轮之后

固定定位会将一个块保持在一个位置不变

上一篇 下一篇

猜你喜欢

热点阅读