【发布时间】:2021-09-14 20:40:51
【问题描述】:
我有点吃不消了。已经搜索和测试了一段时间,但似乎无法让它工作。
这是我目前得到的:
* {
box-sizing: border-box;
}
html, body {
margin: 0;
height: 100%;
font-family: Arial, sans-serif;
}
.container {
position: fixed;
top: 0;
right: 0;
height: 100%;
width: 30%;
background-color: #f9f9f9;
padding: 20px 30px;
}
.box-container {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
height: 100%;
overflow-y: auto;
}
.box {
display: flex;
justify-content: center;
align-items: center;
height: 150px;
width: 49%;
background-color: #FFDAC7;
margin-bottom: 5px;
font-size: 32px;
}
<div class="container">
<h2>lorem ipsum dolor sit amet</h2>
<h3>Some other stuff</h3>
<div class="box-container">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">6</div>
<div class="box">7</div>
<div class="box">8</div>
<div class="box">9</div>
<div class="box">10</div>
</div>
<h5>Maybe a button here</h5>
</div>
现在,我希望“box-container” div 只占用 100% 的可用空间,并且让子级可滚动,但事实并非如此。
似乎我遗漏了一些明显的东西。
这支笔适合喜欢的人,顺便说一句:https://codepen.io/georgiosApo/pen/gORxJwb
提前感谢大家的指点!
// G
【问题讨论】:
-
只需将
overflow-y: auto;添加到.container