css解决fixed布局不会出现滚动条的问题
如果我们布局的是后是fixed并且想要高度为100%的时候,我们一般会这样设置:
width: 100%;
height: auto;
z-index: 9999999;
padding-bottom: 1rem;
position: fixed;
top: 0;
overflow-y: scroll;
overflow-x: hidden;
但是这样并不会出现滚动条,正确的做法应该设置top和bottom为0:
width: 100%;
height: auto;
z-index: 99999999;
padding-bottom: 1rem;
position: fixed;
top: 0;
bottom: 0;
overflow-y: scroll;
overflow-x: hidden;
本文介绍了一种在使用CSS fixed布局时确保垂直滚动条正常显示的方法。通过设置top和bottom属性为0,并结合overflow-y:scroll,可以实现当内容超出容器高度时自动显示滚动条的效果。
3万+

被折叠的 条评论
为什么被折叠?



