在这个HTML结构中
<body>
要素
(demo here)
<div class="grid-1">
<header>
<a href="/">Home</a>
</header>
<main>
<article>
<h1>Test</h1>
<h2 id="overview">Overview</h2>
<p>Lorem ipsum.</p>
<div>
<div>
<pre><code>Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet
Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet
Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet, Lorem, Ipsum, Dolor, Sit, Amet
</code></pre>
</div>
</div>
<h2 id="conclusion">Conclusion</h2>
<p>Lorem ipsum.</p>
</article>
</main>
<footer>
<a href="/">Home</a>
</footer>
如您所见,第二个子元素(即
<main>
元素)具有
<pre>
当此CSS样式表应用于该HTML结构时:
html,
body {
margin: 0;
padding: 0;
}
.grid-1 {
margin-bottom: 50px;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
header {
background: hsl(209, 36%, 90%);
padding: 10px;
}
main {
background: hsl(209, 36%, 80%);
padding: 10px;
}
footer {
background: hsl(209, 36%, 70%);
padding: 10px;
}
pre {
border: 1px solid black;
padding: 10px;
overflow-x: auto;
}
<前>
布洛克,制造
overflow-x: auto;
上
<
块,并将第三列从视图中推到右侧:
grid-template-columns: 1fr 1fr 1fr;
到
grid-template-columns: 1fr minmax(1px, 1fr) 1fr;
,所有三列的宽度和
<前>
布洛克的
overflow-x:自动;
minmax(1px, 1fr)
应该下定决心
1fr