[英]Parent doesn't grow for added scrollbar width in Firefox
When the Child dictates the width of a Parent which has overflow: auto, Firefox doesn't allow space for the added width of a scrollbar (15px) which leaves the Child getting cut off and an overflow-x to appear on the Parent. 当子级指示具有溢出:自动的父级的宽度时,Firefox不允许为滚动条增加的宽度(15px)留出空间,这会使子级被截断,并且在父级上会出现一个溢出x。
What's the best way to fix this issue? 解决此问题的最佳方法是什么?
https://codepen.io/rhysyg03/pen/wrKQJG https://codepen.io/rhysyg03/pen/wrKQJG
.content {
position: absolute;
overflow-y: auto;
min-width:150px;
max-height: 300px;
padding: 8px;
background:white;
border:1px solid rgba(0,0,0,.12);
}
For example, adding padding-right: 15px fixes the issue but then leaves the other browser's with an extra 15px. 例如,添加padding-right:15px可以解决此问题,但其他浏览器则需要额外的15px。
Or adding a fixed width to the Parent fixes issue but then you're bound to a fixed width restriction and I want to leave the Parent flexible. 或为“父级修复”问题添加固定宽度,但是您受到固定宽度限制的约束,而我想让“父级”灵活。
Or adding overflow-x: hidden hides the scrollbar, but leaves the Child cut off. 或添加overflow-x:隐藏隐藏滚动条,但将“子级”保留下来。
Update: display: flex on Parent fixes the issue for regular widths (ie: an image) but not the widths set by text with whitespace: nowrap. 更新:显示:父级上的flex可以解决常规宽度(即图像)的问题,但不能解决带有空白:nowrap的文本设置的宽度问题。
Thanks. 谢谢。
Firefox: Firefox:
Chrome: 铬:
you can use @-moz-document
to write some styles could be recognized by firefox only. 您可以使用
@-moz-document
编写某些样式,这些样式只能由firefox识别。 see this: https://developer.mozilla.org/en-US/docs/Web/CSS/@document . 请参见: https : //developer.mozilla.org/en-US/docs/Web/CSS/@document 。
hopes helpful. 希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.