我有一个 400 像素宽的 DIV,包含两个并排的 DIV,每个 DIV 的宽度为 400 像素,高度为 600 像素。两个 DIV 的宽度是固定的,但高度可以变化。我想隐藏第二个 DIV 并完全显示第一个,在 DIV 内不滚动。
我想,我的解决方案是隐藏溢出-x。这似乎也隐藏了 y 溢出。
这是我的代码:
#schools-sub-nav {
}
#schools-container {
width: 400px; /* Set the width of the visible portion of content here */
background-color: fuchsia;
position: relative;
overflow-x: hidden;
}
#schools-list {
width: 400px; /* Set the width of the visible portion of content here */
height: 600px; /* Delete the height, let the content define the height */
background-color: purple;
position: absolute;
top: 0;
left: 0;
}
#boards-list {
width: 400px; /* Set the width of the visible portion of content here */
height: 600px; /* Delete the height, let the content define the height */
background-color: green;
position: absolute;
top: 0;
left: 400px;
}
<div id="schools-sub-nav"> <a href="#schools-list">Schools List</a> // <a href="#boards-list">Boards List</a> </div>
<div id="schools-container">
<div id="schools-list"> One </div>
<div id="boards-list"> Two </div>
</div>
我希望#schools-list
是可见的,但由于某种原因隐藏了它overflow-x: hidden
。#schools-container