gpt4 book ai didi

html - Bootstrap 4 卡片内容未垂直对齐到中间

转载 作者:太空宇宙 更新时间:2023-11-04 07:45:04 25 4
gpt4 key购买 nike

我有一张卡片,我想垂直对齐卡片中的内容。我实际上已经尝试了此处列出的 bootstrap 4 指南和教程中的所有内容:

https://v4-alpha.getbootstrap.com/utilities/vertical-align/

https://v4-alpha.getbootstrap.com/utilities/flexbox/#align-items

这是我的代码:

<div class="col-sm-12 col-md-4">
<div class="white-card item" data-mh="my-group-2">
<div class="white-card-block h-100 justify-content-center">
<div class="row">
<div class="left-side">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 27.02 20.97">
<defs>
<style>
.cls-1 {
fill: #ed8b00;
fill-rule: evenodd;
}
</style>
</defs>
<g id="Layer_1" data-name="Layer 1">
<g id="Guides">
<path class="cls-1" d="M27,4.1a1.67,1.67,0,0,0-.49-1.2L24.16.49a1.68,1.68,0,0,0-2.37,0L10.35,12.09,5.23,6.88a1.68,1.68,0,0,0-2.37,0L.49,9.29A1.67,1.67,0,0,0,0,10.49a1.7,1.7,0,0,0,.49,1.2L6.8,18.08l2.37,2.4a1.68,1.68,0,0,0,2.37,0l2.37-2.4L26.53,5.3A1.7,1.7,0,0,0,27,4.1Z" />
</g>
</g>
</svg>
</div>
<div class="right-side">
<h4><strong>Easy Installation</strong></h4>
<p>Easy Installation on new or existing electric and gas tanks</p>
</div>
</div>
</div>
</div>

这是我的卡片的 CSS:

.white-card {
margin: 15px 0;
.white-card-block {
.left-side {
display: inline-block;
width: 10%;
margin: 0 5%;
}
.right-side {
display: inline-block;
width: 80%;
p {
margin: 0;
}
}
}
}

这是我的卡片目前的样子的图片:enter image description here

任何帮助都会有所帮助。几个小时以来,我一直在思考我的大脑。提前致谢。 :)

最佳答案

我删除了你的行 div,因为它是不必要的,并用两个类 d-flex align-items-center 替换了类 justify-content-center。我还将这两个类添加到左侧的 div

我在 svg 标签中定义了宽度和高度,因为它没有为我显示

Here is the example in fiddle

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
<div class="col-sm-12 col-md-4">
<div class="white-card item" data-mh="my-group-2">
<div class="white-card-block h-100 d-flex align-items-center">
<div class="left-side d-flex align-items-center">
<svg width="30" height="30" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 27.02 20.97">
<defs>
<style>
.cls-1 {
fill: #ed8b00;
fill-rule: evenodd;
}
</style>
</defs>
<g id="Layer_1" data-name="Layer 1">
<g id="Guides">
<path class="cls-1" d="M27,4.1a1.67,1.67,0,0,0-.49-1.2L24.16.49a1.68,1.68,0,0,0-2.37,0L10.35,12.09,5.23,6.88a1.68,1.68,0,0,0-2.37,0L.49,9.29A1.67,1.67,0,0,0,0,10.49a1.7,1.7,0,0,0,.49,1.2L6.8,18.08l2.37,2.4a1.68,1.68,0,0,0,2.37,0l2.37-2.4L26.53,5.3A1.7,1.7,0,0,0,27,4.1Z" />
</g>
</g>
</svg>
</div>
<div class="right-side">
<h4><strong>Easy Installation</strong></h4>
<p>Easy Installation on new or existing electric and gas tanks</p>
</div>
</div>
</div>
</div>

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>

CSS

.white-card {
margin: 15px 0;
.white-card-block {
.left-side {
display: inline-block;
width: 10%;
margin: 0 5%;
}
.right-side {
display: inline-block;
width: 80%;
p {
margin: 0;
}
}
}
}

关于html - Bootstrap 4 卡片内容未垂直对齐到中间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48211327/

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