我有以下内容:
<html>
<head>
<style>
#outer-grid {
display: grid;
grid-gap:0vh;
grid-template-columns: repeat(2, 1fr) 30px; /*also tried auto in place of 1fr*/
grid-template-rows: repeat(2,1fr);
height: 100vh;
width: 100vw;
position: absolute;
}
</style>
</head>
<body>
<div id='outer-grid'>
<div>item 1</div>
<div>item 2</div>
<div>item 3</div>
<div>item 4</div>
<div>item 5</div>
<div>item 6</div>
</div>
</body>
</html>
这会导致内容超出屏幕宽度,并添加滚动条(Firefox)。我期望的是右侧列固定在右边缘。我做错了什么?
浏览器在这种情况下如何计算总宽度?
top:0;left:0
添加到绝对定位元素。 - Temani Afif