标题重写为:HTML元素高度未达到100%的覆盖
P粉359850827
P粉359850827 2023-09-15 08:52:48
[CSS3讨论组]

我希望这个元素覆盖屏幕高度的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%;
}

P粉359850827
P粉359850827

全部回复(1)
P粉014293738

使用此代码作为body:

body {
    height: 100vh;
}
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号