html - 如何使这部分全屏高度?无论我们做什么,它都会在底部留下空白
问题描述
我们正在尝试使内容完全占据屏幕高度,但无论我们做什么,它都会在屏幕底部显示空白。怎么可能修复?
section {
height: 100vh;
background-size: cover;
background: #FF512F;
/* fallback for old browsers */
background: -webkit-linear-gradient(to right, #FF512F, #DD2476);
/* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to right, #FF512F, #DD2476);
padding-top: 5%;
/* New code */
overflow: hidden;
padding-top: 80px;
margin-top: -100px;
height: 150%;
}
.emp-profile {
padding: 10%;
border-radius: 0.5rem;
background: #fff;
margin-top: 80px;
margin-bottom: 80px
}
<section *ngIf="user" (onlineUsers)="online($event)">
<div class="container">
<div class="emp-profile justify-content-center">
... ...
</div>
</div>
</section>
我不能使用 body 标签,因为这是一个有角度的独立组件,并且从该部分开始。
如何使该部分成为屏幕的全高?我们正在使用带有 Angular 6 的 Bootstrap 4
解决方案
该部分有负边距。这会将整个部分向上移动 150 像素。也不要在 CSS 中定义高度两次。无论负边距是多少,它都必须加回高度......
section {
height: calc(100vh + 80px);
background-size: cover;
background: #FF512F; /* fallback for old browsers */
background: -webkit-linear-gradient(to right, #FF512F, #DD2476);
background: linear-gradient(to right, #FF512F, #DD2476);
padding-top: 80px;
margin-top: -80px;
}
推荐阅读
- java - python中tf.train.Example.SerializeToString的tensorflow java API是什么?
- javascript - 在textarea中替换脚本后如何保持光标位置相同?
- python - 如何从导入的类中添加数据
- python - python中函数内部的参数
- c++ - C++ std::reduce 与数组
- java - 在类之间传递二维数组列表
- html - 如何在文本后面画一条粗线?
- node.js - 测试时未找到 TypeORM 连接
- javascript - React js 多选 [object Object], [object Object]
- c# - 如何将控制台cmd的输出通过管道传输到另一个类的TextBox