[英]firefox flex doesn't grow for scrollbar
I am having trouble with an issue specific to firefox (afaik). 我遇到了一个特定于firefox(afaik)的问题。
In chrome if you have 如果你有铬合金
flex: 0 0 auto;
overflow: auto;
when there is overflow in y direction, it accounts for the extra width of the scrollbar and everything is fine. 当y方向溢出时,它会占据滚动条的额外宽度,一切都很好。 But in firefox it doesn't account for the extra width and it makes the content to overflow in the x direction as well. 但是在Firefox中,它没有考虑额外的宽度,它也使内容在x方向上溢出。
I have prepared a pen that demonstrates this issue: 我准备了一支笔来演示这个问题:
https://codepen.io/anon/pen/JEMyPm https://codepen.io/anon/pen/JEMyPm
firefox: 火狐:
chrome: 铬:
Any suggestion/workarounds would be awesome! 任何建议/解决方法都会很棒!
EDIT: flex-grow: 1 (1 1 auto) can fix the problem, that makes the container to respond to the extra space around it by growing. 编辑:flex-grow:1(1 1 auto)可以解决问题,使容器通过增长来响应周围的额外空间。 What if you don't want the element to grow and only be as wide as the content inside? 如果您不希望元素增长并且只与内部内容一样宽,该怎么办?
Please use flex: 1 1 auto
instead of 0 0 auto
, as It sizes the item based on its width/height
properties, but makes it fully flexible so that they absorb any extra space along the main axis. 请使用flex: 1 1 auto
而不是0 0 auto
,因为它根据width/height
属性调整项目大小,但使其完全灵活,以便沿主轴吸收任何额外空间。 defined below: 定义如下:
.child {
flex: 1 1 auto;
width: 50px;
height: 50px;
background: #000;
color: #fff;
margin: 8px;
text-align: center;
line-height: 50px;
border: 3px solid #4d4d50;
border-radius: 2px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.