有时候想实现fixed定位的效果但是又不想用fixed定位,就写了个demo,absolute模拟fixed定位
<div class="div1">
<div class="dd1">
<div class="d1">
a<br>b<br>c<br>d<br>e<br>f<br>g<br>h<br>i
</div>
</div>
<div class="d2">
1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9
</div>
</div>
<style type="text/css">
.div1 {
position: absolute;
width: 300px;
height: 300px;
background-color: #ccc;
}
.dd1 {
width: 100%;
height: 100%;
overflow: auto;
}
.d1 {
width: 80%;
height: 400px;
background: lime;
}
.d2 {
position: absolute;
right: 0;
top: 0;
width: 100px;
height: 100px;
background-color: yellow;
overflow: scroll;
}
</style>
贴张图吧