html - 如何降低高度并同时使其在 Bootstrap 4 中响应
问题描述
我想降低图像高度,使其占据屏幕的 75%。我尝试使用 height: 75%; 和 class="h-75" 但这似乎不起作用。现在我有 class="h-800" 然后 h-800 { height: 800px; 但这并不能使其响应。
我想要的一个很好的例子:https ://heydays.no/
这是我的 HTML:
<div id="" class="carousel slide" data-ride="carousel" data-interval="3000" data-pause="false">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://images.pexels.com/photos/1779487/pexels-photo-1779487.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" class="h-800" alt="...">
</div>
<div class="carousel-item">
<img src="https://images.pexels.com/photos/1999463/pexels-photo-1999463.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" class="h-800" alt="...">
</div>
</div>
</div>
和 CSS:
img {
height: 75%;
object-fit: cover;
width: 100%;
}
.h-800 {
height: 800px;
}
解决方案
您可以使用视口高度。
在这个例子中,我正在创建一个类.h75
.h75{
height: 75vh;
}
推荐阅读
- javascript - 如何在 React JS 中动态添加子数组输入字段
- javascript - 在 setTimeout 之后更改 translateX
- azure - Azure Key Vault 在 AKS 中使用管理标识
- pytorch - 如何使用pytorch多处理分别训练模型
- c - 为什么我得到 free(): invalid pointer?
- archlinux - cal 命令在 startx 和 lightdm 之间的行为不同
- node.js - 如何从 Mongoose Graphql 的一对一关系的反向模型中获取数据?
- android - Android:在片段中定义的应用栏中覆盖向上导航
- html - 图像、字体、网站图标等仅出现在 Safari 中,但不在 Chrome 或移动设备中?
- visual-studio-code - VSCode:将光标移动到每个光标的给定单词的下一个出现