我有一个简单的网页,其中心内容为红色背景。我希望该背景颜色一直到达页面底部,无论其中是否有那么多内容。
我尝试了各种方法组合,但似乎没有任何方法可以正确拉伸它。在 Fiddle 中,我尝试使用 flexbox,但它似乎不起作用。
body {
background-color: white;
}
.main {
max-width: 80%;
background-color: red;
margin: 0 auto;
padding: 10px;
display: flex;
align-content: stretch;
flex-direction: row;
}
<section class="main">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at aliquam dolor. Pellentesque a nibh in magna blandit elementum. Sed sodales porttitor dolor vel bibendum. Ut viverra justo in elit scelerisque, nec accumsan arcu facilisis. Nam ultricies
leo vitae felis sollicitudin lobortis. Cras nec nibh venenatis, bibendum neque at, suscipit lacus. Vestibulum interdum sodales cursus. Pellentesque feugiat eu velit venenatis egestas. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam
faucibus risus quis est pellentesque ultrices.
</p>
</section>
<section class="main">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</p>
</section>
body
{
background-color:white;
}
.main
{
max-width:80%;
background-color:red;
margin: 0 auto;
padding: 10px;
display:flex;
align-content:stretch;
flex-direction:row;
}