【发布时间】:2019-12-16 20:03:49
【问题描述】:
我试图让.navbar 屏幕的一半,但它没有正确显示。我不确定为什么?我猜还有另一个容器,但我不知道为什么?
我将 body 设置为 100vh 以覆盖屏幕
我有
.navbar使用百分比的一半
html 文件:
body {
background-color: red !important;
width: 100vh;
height: 100vh;
}
.navbar{
width: 50%;
background-color: white;
}
.navbarButtons{
background-color: aqua;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="navbar">
<div class="navbarButtons">
<button type="button" class="btn btn-outline-primary">Primary</button>
<button type="button" class="btn btn-outline-primary">Primary</button>
<button type="button" class="btn btn-outline-primary">Primary</button>
<button type="button" class="btn btn-outline-primary">Primary</button>
<button type="button" class="btn btn-outline-primary">Primary</button>
</div>
</div>
【问题讨论】:
-
你应该为 .navbar 类添加 height:50vh
-
从 .all 类中移除宽度和高度
-
% 不接受弹性高度和窗口高度
-
从 .all 类中删除宽度或在该类中使用 width: 100vw
-
你想在哪里包含图片?
标签: html css django bootstrap-4