Woj*_*Maj 7 css internet-explorer css3 flexbox
我有一个父元素,包含两个子元素,使用flexbox显示在彼此之上.此父元素的max-height属性设置为特定值.因此,只要内容很短,父元素应该保持较小,随着内容的增长,父元素随之增长,直到满足其最大高度.此时我们应该在内容元素上看到滚动条.
#container {
display: flex;
max-width: 80vw;
max-height: 100px;
flex-direction: column;
}
#content {
overflow-y: auto;
}
/* styling - ignore */
#container {
border: 2px solid black;
margin-bottom: 1em;
}
#header {
background-color: rgb(245, 245, 245);
padding: 10px;
}
#content {
background-color: rgb(255, 255, 255);
padding: 0 10px;
}Run Code Online (Sandbox Code Playgroud)
<div id="container">
<div id="header">Header</div>
<div id="content">
<p>Everything works as supposed to, move along</p>
</div>
</div>
<div id="container">
<div id="header">Header</div>
<div id="content">
<p>Very long content</p>
<p>Very long content</p>
<p>Very long content</p>
<p>Very long content</p>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
这适用于Firefox和Chrome.在Internet Explorer上,虽然未显示内容元素中的滚动条; 相反,内容元素从父元素溢出.
我试着玩flex-basis和其他flexbox属性,google了很多,但没有任何运气.
尝试使用 height: 100px 而不是 max-height: 100px;在#container上,即:
#container {
display: flex;
max-width: 80vw;
height: 100px;
flex-direction: column;
}
Run Code Online (Sandbox Code Playgroud)
#container {
display: flex;
max-width: 80vw;
height: 100px;
flex-direction: column;
}
Run Code Online (Sandbox Code Playgroud)
#container {
display: flex;
max-width: 80vw;
height: 100px;
flex-direction: column;
}
#content {
overflow-y: auto;
}
/* styling - ignore */
#container {
border: 2px solid black;
margin-bottom: 1em;
}
#header {
background-color: rgb(245, 245, 245);
padding: 10px;
}
#content {
background-color: rgb(255, 255, 255);
padding: 0 10px;
}Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2348 次 |
| 最近记录: |