如何使ul可滚动?现在看来ul ulbox只是在浏览器窗口之外增长。
HTML
<div class="container">
<div class="header">
Untitled
</div>
<ul/>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
</ul>
</div>
CSS
body, html {
overflow: hidden;
}
.container {
display: flex;
flex-direction: column;
}
ul {
flex: 1;
overflow-y: auto;
}
答案 0 :(得分:1)
<强> Demo 强>
CSS
html, body {
height: 100%;
overflow: hidden;
}
.container {
display: -webkit-flex;
-webkit-flex-direction: column;
height: 100%;
width: 50%;
background-color: red;
}
.header {
background-color: gray;
}
ul {
-webkit-flex: 1 1 auto;
overflow-y: auto;
min-height: 0px;
}