简体   繁体   English

溢出属性在IE 11中不起作用

[英]Overflow property not working in IE 11

My code below works fine in most browsers (Chrome, Firefox, Safari, Edge) but does not seem to work in IE11. 我的代码在大多数浏览器(Chrome,Firefox,Safari,Edge)中运行良好,但在IE11中似乎不起作用。

I'm reading about the Known Issues at caniuse but it doesn't seem to say anything about IE11 and overflow . 我正在阅读关于caniuse的已知问题,但它似乎没有说任何有关IE11和overflow Is this a bug in IE 11 or am I missing something? 这是IE 11中的错误还是我错过了什么?

 .container { display: flex; max-height: 100px; flex-direction: column; border: 1px solid red; } .header { background: #eee; } .container > div { flex: 0 0 auto; } .container > div.content { flex: 0 1 auto; overflow: auto; } 
 <div class="container"> <div class="header">Header without specific height. Always stays at top of .container, even if it is so long it uses up two lines.</div> <div class="content"> <div>Item no 1 in long list</div> <div>Item no 2 in long list</div> <div>Item no 3 in long list</div> <div>Item no 4 in long list</div> <div>Item no 5 in long list</div> <div>Item no 6 in long list</div> <div>Item no 7 in long list</div> <div>Item no 8 in long list</div> <div>Item no 9 in long list</div> <div>Item no 10 in long list</div> <div>Item no 11 in long list</div> <div>Item no 12 in long list</div> </div> </div> 

As you noted, IE11 has many problems rendering flexbox. 如你所述,IE11在渲染flexbox时遇到很多问题。 The fact that you haven't found documentation about this particular issue could just mean it hasn't been documented yet. 您没有找到有关此特定问题的文档的事实可能只是意味着它尚未被记录。 But it does appear to be a bug. 但它似乎确实是一个错误。

In terms of the overflow property, IE11 will apply overflow: visible , regardless of the actual value, unless a width or height is declared . overflow属性而言,IE11将应用overflow: visible ,无论实际值如何, 除非声明宽度或高度

In your case, simply switching from flex-basis: auto to flex-basis: 75px (just an example), fixes the scrollbar issue. 在您的情况下,只需从flex-basis: autoflex-basis: 75px (仅举例),修复滚动条问题。

As a fixed height is not what you're looking for, you could try targeting styles for just IE11 . 由于固定高度不是您想要的,您可以尝试仅针对IE11定位样式

 .container { display: flex; max-height: 100px; flex-direction: column; border: 1px solid red; } .header { background: #eee; } .container > div { flex: 0 0 auto; } .container > div.content { flex: 0 1 75px; /* adjusted */ overflow: auto; } 
 <div class="container"> <div class="header">Header without specific height. Always stays at top of .container, even if it is so long it uses up two lines.</div> <div class="content"> <div>Item no 1 in long list</div> <div>Item no 2 in long list</div> <div>Item no 3 in long list</div> <div>Item no 4 in long list</div> <div>Item no 5 in long list</div> <div>Item no 6 in long list</div> <div>Item no 7 in long list</div> <div>Item no 8 in long list</div> <div>Item no 9 in long list</div> <div>Item no 10 in long list</div> <div>Item no 11 in long list</div> <div>Item no 12 in long list</div> </div> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM