如何使此选项隐藏起来,以便我可以使用卷轴来触及它们?
意思选项像“下” DIV,所以我可以滚动到达它们?
这是CSS代码:
aside {
background-color: #E63946;
height: 100%;
width: 100%;
grid-column: 1;
grid-row: 2/5;
display: grid;
place-items: center;
grid-template-rows: repeat(5,1fr);
}
还尝试添加溢出Y:scroll;
,但不起作用。 在这里它的外观。
The question is: What can i do to prevent that and make the other options go like 'under' the div, so i can scroll to reach them?
this is the css code:
aside {
background-color: #E63946;
height: 100%;
width: 100%;
grid-column: 1;
grid-row: 2/5;
display: grid;
place-items: center;
grid-template-rows: repeat(5,1fr);
}
Also tried adding overflow-y: scroll;
but didn't work. here its how it look like.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
Overflow-Y:Scroll
,并在div
容器上设置固定高度是正确的,但这不是完整的答案。网格中“选项”之所以溢出的原因是,网格行的高度设置为
1fr
和元素的高度(div
s?)包含“选项”文本未固定。这意味着“选项”元素的高度将调整以适合网格内部。但是,如果您添加了许多“选项”,它们将溢出,以至于元素的高度成为其包含的文本的高度。尝试在网格中添加50个“选项”,您会看到滚动条。如果您不想添加50个“选项”,而只想要溢出一些,请在网格行上设置固定高度(例如,
网格 - 板板行:重复(8,100px)
)或“选项”元素本身,保持溢出Y:滚动
以及div
容器上的固定高度。Using
overflow-y: scroll
and setting a fixed height on thediv
container is correct but it's not the complete answer.The reason why the 'options' in the grid are not overflowing is because the height of the grid's rows is set to
1fr
and the height of the elements (div
s?) containing the 'option' text is not fixed. This means that the height of the 'option' elements will adjust to fit inside the grid. However, they will overflow if you add so many 'options' that the elements' height become the height of the text they contain. Try adding 50 'options' in the grid and you will see a scrollbar.If you don't want to add 50 'options' and only want a few to overflow, set a fixed height on the grid rows (eg.
grid-template-rows: repeat(8, 100px)
) or on the 'option' elements themselves, keepingoverflow-y: scroll
and a fixed height on thediv
container, of course.在选项容器上使用
Overflow-Y:scroll;
,并将其设置为固定高度。这是示例
Use
overflow-y: scroll;
on the options container and set it to a fixed height.Here are examples