将overflow-y添加到块元素会导致宽度减小。
这就是我所拥有的,我有左 div 和右 div。左边的div是固定宽度的,并且向左浮动。右边的 Div 是一个“display: block”,使其成为全宽,并且左边有一个边距来补偿左边的 div。两个盒子都有固定的高度,并且需要可滚动(里面的内容)。我成功地将溢出-y 添加到左侧 div 中。但是,当我将 Overflow-y: auto 添加到右侧 div 时,该 div 不再跨越整个 div。
添加溢出之前: http://jsbin.com/asecuy/
添加溢出后: http://jsbin.com/asecuy/2
This is what I have, I have left div, and a right div. The left div is a fixed width, and floated left. The right Div is a "display: block" to make it full width, and has a margin on the left to compensate for the left div. Both of the boxes have a fixed height, and need to be scrollable (the contents inside). I add an overflow-y to the Left div successfully. However when I add overflow-y: auto to the right div, the div no longer spans the whole div.
Before adding Overflow:
http://jsbin.com/asecuy/
After adding Overflow:
http://jsbin.com/asecuy/2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要取消设置
此边距导致错误。我猜它只是与溢出-y 和它旁边的浮动效果不太好(尽管我认为应该可以)。
它在这里工作:
http://jsbin.com/asecuy/3/#html
You need to unset
This margin is causing the bug. I'm guessing it just doesn't play nice together with overflow-y and the float next to it (should work though I think).
Here it is working:
http://jsbin.com/asecuy/3/#html