【发布时间】:2018-03-21 04:34:36
【问题描述】:
我想知道为什么position: sticky 适用于某些 x 轴滚动,但是一旦您滚动超过屏幕宽度的初始宽度,您的“粘性 div”就停止了。
在这个例子中,我有一个左侧栏(请注意,我不能使用position: fixed 或position: absolute,因为在我的实际项目中,left-div 和 right-div需要沿 y 轴上下滚动,因此我们只需要左侧粘贴)
有没有我可以定义的额外CSS参数,比如
left-sticky-distance=999999%
或者类似的?
一些测试代码说明如下
<html>
<body>
<div style='
position:sticky;
z-index:1;
left:0;
width:100px;
height:200px;
overflow: hidden;
background-color:#ff0000;
opacity:0.8;'
>
</div>
<div style='position: absolute; top: 10; left: 10; width: 200; height:50px; background-color: blue'>B</div>
<div style='position: absolute; top: 10; left: 110; width: 200; height:50px; background-color: blue'>C</div>
<div style='position: absolute; top: 10; left: 210; width: 200; height:50px; background-color: blue'>D</div>
</body>
<html>
【问题讨论】:
-
你能做一个小提琴之类的吗?
-
或者堆栈溢出sn-p