如何使此选项隐藏起来,以便我可以使用卷轴来触及它们?

发布于 2025-02-07 05:08:51 字数 521 浏览 2 评论 0原文

这是我的

意思选项像“下” 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;,但不起作用。 在这里它的外观。

here is what i mean

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

宁愿没拥抱 2025-02-14 05:08:51

使用Overflow-Y:Scroll,并在div容器上设置固定高度是正确的,但这不是完整的答案。

网格中“选项”之所以溢出的原因是,网格行的高度设置为1fr和元素的高度(div s?)包含“选项”文本未固定。这意味着“选项”元素的高度将调整以适合网格内部。但是,如果您添加了许多“选项”,它们将溢出,以至于元素的高度成为其包含的文本的高度。尝试在网格中添加50个“选项”,您会看到滚动条。

如果您不想添加50个“选项”,而只想要溢出一些,请在网格行上设置固定高度(例如,网格 - 板板行:重复(8,100px) )或“选项”元素本身,保持溢出Y:滚动以及div容器上的固定高度。

Using overflow-y: scroll and setting a fixed height on the div 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 (divs?) 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, keeping overflow-y: scroll and a fixed height on the div container, of course.

童话 2025-02-14 05:08:51

在选项容器上使用Overflow-Y:scroll;,并将其设置为固定高度。
这是示例

Use overflow-y: scroll; on the options container and set it to a fixed height.
Here are examples

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文