Adding overflow-y to block element causes width to decrease.

∥☆過路亽.° 提交于 2019-12-08 04:41:25

问题


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


回答1:


You need to unset

.eventdetails {
    margin-left: 252px;
}

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



来源:https://stackoverflow.com/questions/7504896/adding-overflow-y-to-block-element-causes-width-to-decrease

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!