我希望这个元素覆盖屏幕高度的100%,显然没有这样做,有什么解决方法吗? 我看到div的高度是section的100%,而section的高度是body的100%,而body被设置为100%。
<body>
<section id="Block1">
<div class="firstsection">
<h1>Lorem Ipsum</h1>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nemo magnam iusto quibusdam quas reiciendis fugit architecto consequatur similique distinctio dolore repudiandae rem illo alias iure sunt eos culpa, amet consectetur!</p>
</div>
</section>
</body>
CSS
body {
width: 100%;
height: 100%;
}
* {
padding: 0px;
margin: 0px;
}
.firstsection {
width: 50%;
height: 100%;
background-color: yellowgreen;
text-align: center;
}
#Block1 {
width: 100%;
height: 100%;
}
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
使用此代码作为body:
body { height: 100vh; }