我使用CSS位置的黏性值时,顶部DIV高度不是int值,而是一个浮点值,然后将底部div的顶部一样顶部的高度,这将让他们之间的空间!但使用绝对和固定不存在这个问题。CSS粘位置浮动错误
一个div和b DIV有空间
html,body {
margin: 0;
}
.container {
height: 1000px;
}
.container > div {
height: 65.9px;
}
.a {
position: sticky;
/* position: static */
/* position: sticky */
width: 340px;
top: 0px;
background: green;
z-index: 20;
}
.b {
position: sticky;
top: 66px;
/* top: 65.9 */
width: 100px;
z-index: 10;
background: pink;
over-flow: hidden;
}
.c {
position: fixed;
width: 100px;
left: 120px;
top: 66px;
background: red;
}
.d {
position: absolute;
width: 100px;
left: 240px;
top: 66px;
background: yellow;
}
<!-- position sticky float number bug -->
<div class="container">
<div class="a">a: height=65.9px sticky position</div>
<div class="b">b: top=66px sticky position</div>
<div class="c">c: top=66px fixed position</div>
<div class="d">d: top=66px absolute</div>
</div>
有人能帮我看看吗?
我不清楚:),哪里是floatting车元素?它会在哪里出错? –
div和b div有空间 – marchen
有空间在哪里? – LGSon