gpt4 book ai didi

html - 具有固定大小滚动的 CSS 网格 : How to solve issue where bottom margin/padding isn't shown?

转载 作者:太空宇宙 更新时间:2023-11-03 19:26:57 26 4
gpt4 key购买 nike

编辑:

所以我看到了指向的重复链接,在我看来,这个问题是为了解决你给出固定大小(固定宽度或固定高度)的问题。

原始问题的解决方案更多是关于使用 hacky 方法修复容器。我决定采用不同的方法来解决它,同时解决我自己在这个问题中提出的问题。


在 CSS 中,当使用 display: gridfixed height 时,打开 overflow: auto,你可能会得到这种布局,如下所示:

.scroll {
overflow: auto;
background-color: #bbddee;
}

.container {
padding: 10px;
display: grid;
grid-template-columns: 1fr;
grid-row-gap: 10px;
height: 420px;
}

.itemContainer {
border: 1px solid #efefef;
padding: 10px 20px;
background-color: #fff;
}

.itemTitle {
text-align:center;
margin: 0 auto;
}

.itemLink {
text-align: center;
margin: 0 auto;
}
<div id="retailerContent" class="tab-pane fade in active show">
<div class="scroll">
<div id="retailerOffersContainer" class="container">

<div class="itemContainer">
<div class="itemTitle">15% Off Room Essentials Cubes &amp; Bins</div>
<div class="itemLink"><a>Get Offer&nbsp;&gt;</a></div>
</div>
<div class="itemContainer">
<div class="itemTitle">15% Off Room Essentials Cubes &amp; Bins</div>
<div class="itemLink"><a>Get Offer&nbsp;&gt;</a></div>
</div>
<div class="itemContainer">
<div class="itemTitle">15% Off Room Essentials Cubes &amp; Bins</div>
<div class="itemLink"><a>Get Offer&nbsp;&gt;</a></div>
</div>
<div class="itemContainer">
<div class="itemTitle">15% Off Room Essentials Cubes &amp; Bins</div>
<div class="itemLink"><a>Get Offer&nbsp;&gt;</a></div>
</div>
<div class="itemContainer">
<div class="itemTitle">15% Off Room Essentials Cubes &amp; Bins</div>
<div class="itemLink"><a>Get Offer&nbsp;&gt;</a></div>
</div>
<div class="itemContainer">
<div class="itemTitle">15% Off Room Essentials Cubes &amp; Bins</div>
<div class="itemLink"><a>Get Offer&nbsp;&gt;</a></div>
</div>
<div class="itemContainer">
<div class="itemTitle">15% Off Room Essentials Cubes &amp; Bins</div>
<div class="itemLink"><a>Get Offer&nbsp;&gt;</a></div>
</div>
<div class="itemContainer">
<div class="itemTitle">15% Off Room Essentials Cubes &amp; Bins</div>
<div class="itemLink"><a>Get Offer&nbsp;&gt;</a></div>
</div>
<div class="itemContainer">
<div class="itemTitle">15% Off Room Essentials Cubes &amp; Bins</div>
<div class="itemLink"><a>Get Offer&nbsp;&gt;</a></div>
</div>
<div class="itemContainer">
<div class="itemTitle">15% Off Room Essentials Cubes &amp; Bins</div>
<div class="itemLink"><a>Get Offer&nbsp;&gt;</a></div>
</div>
<div class="itemContainer">
<div class="itemTitle">15% Off Room Essentials Cubes &amp; Bins</div>
<div class="itemLink"><a>Get Offer&nbsp;&gt;</a></div>
</div>
<div class="itemContainer">
<div class="itemTitle">15% Off Room Essentials Cubes &amp; Bins</div>
<div class="itemLink"><a>Get Offer&nbsp;&gt;</a></div>
</div>
<div class="itemContainer">
<div class="itemTitle">15% Off Room Essentials Cubes &amp; Bins</div>
<div class="itemLink"><a>Get Offer&nbsp;&gt;</a></div>
</div>

</div>
</div>
</div>

发生这种情况时,会出现滚动列表底部没有填充/边距的问题。应如何修改 HTML 和 CSS,以便底部填充/边距显示在可滚动的 CSS 网格布局中?

最佳答案

这是我在使用 CSS 网格时的修复:

/* Fix scrollbar removing padding-bottom */
@supports (-moz-appearance:none) {
.container::after {
content: "";
height: 1px;
margin: calc(var(--padding) - var(--gap));
}
}

关于html - 具有固定大小滚动的 CSS 网格 : How to solve issue where bottom margin/padding isn't shown?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50118718/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com