给你的容器相对定位和添加top:100% 到副轮
* {
box-sizing: border-box;
}
.container {
width: 300px;
border: 1px solid #000;
position:relative;
}
.mainrow, .subrows div {
width: 100%;
padding: 10px
}
.mainrow {
background: #CCC;
}
.subrows {
position: absolute;
width: 100%;
max-height: 100px;
top: 100%;
margin-top: 1px; /* for container border to show */
left: 0;
overflow: auto;
}
.subrows div {
background: #DDD;
}
<div class="container">
<div class="mainrow">First row</div>
<div class="subrows">
<div>Sub row 1</div>
<div>Sub row 2</div>
<div>Sub row 3</div>
<div>Sub row 4</div>
<div>Sub row 5</div>
<div>Sub row 6</div>
<div>Sub row 7</div>
<div>Sub row 8</div>
<div>Sub row 9</div>
<div>Sub row 10</div>
</div>
</div>
从容器的边界可以看到,它没有扩展到适合子窗口(我不知道为什么您要这样做,因为主线下的任何内容现在都将被子窗口覆盖)