以下HTML将在div.container的右侧内侧边缘显示滚动条.
是否可以确定滚动条的宽度?
<div class="container" style="overflow-y:auto; height:40px;">
<div class="somethingBig"></div>
</div>
Run Code Online (Sandbox Code Playgroud) 尽管我还没有找到答案,但问题很简单:除了蛮力之外,还有什么方法 可以计算响应网格中的列数?
#grid-container {
width: 100%;
height: 85%;
position: relative;
padding: var(--gap); /* adjusted with JS to make var(--gap) responsive */
display: grid;
grid-gap: var(--gap); /* adjusted with JS to make var(--gap) responsive */
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
box-sizing: border-box;
background: skyblue;
}
.grid-item {
width: 100%;
min-width: 120px;
max-width: 450px;
height: ; /* adjusted with JS on resize events to roughly maintain proportions */
min-height: 192px;
border-radius: 10px;
background: #333;
}
Run Code Online (Sandbox Code Playgroud)
我问的原因是因为我给网格项目a max-width
导致了最后一个断点处的巨大间隙,我希望能够检测到该间隙,而不是设置显式的媒体查询。