html - 封面页高度设置为 100% 有一半
问题描述
我一直在尝试实现一个引导封面页模板,但我很难设置它。我确实能够从 bootstraps 网站将代码复制到我的,这导致封面页占据了一半的高度。在样式中,它显然有 height: 100%,但是如果我将高度更改为不同的百分比,它根本不会影响它。但是,如果我将高度更改为 740 像素,它最终会成为我屏幕的相对高度,但这会在未来出现问题。为什么身高百分比不会影响它?
a,
a:focus,
a:hover {
color: #fff;
}
/* Custom default button */
.btn-secondary,
.btn-secondary:hover,
.btn-secondary:focus {
color: #333;
text-shadow: none; /* Prevent inheritance from `body` */
background-color: #fff;
border: .05rem solid #fff;
}
/*
* Base structure
*/
html,
body {
height: 740px;
background-color: #aaa;
}
body {
display: -ms-flexbox;
display: -webkit-box;
display: flex;
-ms-flex-pack: center;
-webkit-box-pack: center;
justify-content: center;
color: #fff;
text-shadow: 0 .05rem .1rem rgba(0, 0, 0, .5);
box-shadow: inset 0 0 5rem rgba(0, 0, 0, .5);
}
.cover-container {
max-width: 42em;
}
/*
* Header
*/
.masthead {
margin-bottom: 2rem;
}
.masthead-brand {
margin-bottom: 0;
}
.nav-masthead .nav-link {
padding: .25rem 0;
font-weight: 700;
color: rgba(255, 255, 255, .5);
background-color: transparent;
border-bottom: .25rem solid transparent;
}
.nav-masthead .nav-link:hover,
.nav-masthead .nav-link:focus {
border-bottom-color: rgba(255, 255, 255, .25);
}
.nav-masthead .nav-link + .nav-link {
margin-left: 1rem;
}
.nav-masthead .active {
color: #fff;
border-bottom-color: #fff;
}
@media (min-width: 48em) {
.masthead-brand {
float: left;
}
.nav-masthead {
float: right;
}
}
/*
* Cover
*/
.cover {
padding: 0 1.5rem;
}
.cover .btn-lg {
padding: .75rem 1.25rem;
font-weight: 700;
}
/*
* Footer
*/
.mastfoot {
color: rgba(255, 255, 255, .5);
}
解决方案
你可以试试这个
html, body {
height: 100vh;
min-height: 100vh;
background-color: #aaa;
}
推荐阅读
- c# - Windows 10/C# - 仅从开始菜单运行时长文件名失败
- python - LSTM 预测
- websocket - 属性错误:pyopenssl 20.0.1 中的 __enter__
- java - AnyLogic,代理移动到多个位置并返回原始位置
- azureservicebus - “message.DeliveryCount”引发了“System.InvalidOperationException”类型的异常
- random - Jmeter:测试脚本中的 24 位随机数
- python - 如何忽略用户未通过 SQLITE 的条件?
- json - 如何从具有值 {[]} 的 Jarray 中获取 []
- python - 无法使用 conda install 或 pip 安装 scanpy 包
- javascript - 如何解构对象中的数组并重命名从中创建的变量?