gpt4 book ai didi

html - 如何在 Bootstrap 4 上让所有列的高度和边距相同?

转载 作者:行者123 更新时间:2023-11-28 16:16:57 25 4
gpt4 key购买 nike

我想将我的元素包裹在一个带有框阴影和圆 Angular 边框的矩形内,我还希望它们具有相同的高度和响应能力(这就是为什么我不直接设置最大高度或高度等)

这是我想要实现的:

enter image description here

这就是我目前所拥有的:

enter image description here

这是我的代码:

<div class="row">
<div class="col-12">
<h2 class="sm-header-title mb-5">Nuestros viajes de esquí organizados</h2>
</div>
<div class="col-3 rectangle-holder p-5">
<h2 class="sm-header-title">Viajes escolares</h2>
</div>
<div class="col-3 rectangle-holder p-5">
<h2 class="sm-header-title">Viajes universitarios</h2>
</div>
<div class="col-3 rectangle-holder p-5">
<h2 class="sm-header-title">Viajes para empresas</h2>
</div>
<div class="col-3 rectangle-holder p-5">
<h2 class="sm-header-title">Otros tipo de grupos</h2>
</div>
</div>

和CSS:

.sm-header-title {
font-size: 30px;
font-weight: 800;
color: #3490dc;
}

.rectangle-holder {
border-radius: 10px;
box-shadow: 0 2px 7px 0 rgba(0, 0, 0, 0.3);
background-color: white;
}

<!DOCTYPE html>
<html>
<head>
<title></title>
<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">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

<style>
.sm-header-title {
font-size: 30px;
font-weight: 800;
color: #3490dc;
}

.rectangle-holder {
border-radius: 10px;
box-shadow: 0 2px 7px 0 rgba(0, 0, 0, 0.3);
background-color: white;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-12">
<h2 class="sm-header-title mb-5">Nuestros viajes de esquí organizados</h2>
</div>
<div class="col-3 rectangle-holder p-5">
<h2 class="sm-header-title">Viajes escolares</h2>
</div>
<div class="col-3 rectangle-holder p-5">
<h2 class="sm-header-title">Viajes universitarios</h2>
</div>
<div class="col-3 rectangle-holder p-5">
<h2 class="sm-header-title">Viajes para empresas</h2>
</div>
<div class="col-3 rectangle-holder p-5">
<h2 class="sm-header-title">Otros tipo de grupos</h2>
</div>
</div>
</div>
</body>
</html>

最佳答案

将所有 h2 包装在 divh-100 类中,以及您添加到列 div 中的其他类。

.sm-header-title {
font-size: 30px;
font-weight: 800;
color: #3490dc;
}

.rectangle-holder {
border-radius: 10px;
box-shadow: 0 2px 7px 0 rgba(0, 0, 0, 0.3);
background-color: white;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row ">
<div class="col-12">
<h2 class="sm-header-title mb-5">Nuestros viajes de esquí organizados</h2>
</div>
<div class="col-3">
<div class="rectangle-holder p-5 h-100">
<h2 class="sm-header-title">Viajes escolares</h2>
</div>
</div>
<div class="col-3">
<div class="rectangle-holder p-5 h-100">
<h2 class="sm-header-title">Viajes universitarios</h2>
</div>
</div>
<div class="col-3">
<div class="rectangle-holder p-5 h-100">
<h2 class="sm-header-title">Viajes para empresas</h2>
</div>
</div>
<div class="col-3">
<div class="rectangle-holder p-5 h-100">
<h2 class="sm-header-title">Otros tipo de grupos</h2>
</div>
</div>
</div>

关于html - 如何在 Bootstrap 4 上让所有列的高度和边距相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57991726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com