gpt4 book ai didi

html - 如何修复图标对齐?

转载 作者:行者123 更新时间:2023-11-27 23:38:33 25 4
gpt4 key购买 nike

我正在尝试创建一个简单的 html 页面,但我无法对齐其中一个图标。我不明白我的 CSS 或 HTML 哪里出了问题。

这是我的 html 页面的图片:

here is the pic of my html page

.service-icon-container {
display: table;
width: 100%;
height: 80px;
color: #FCDB7A;
font-size: 65px;
}

.service-icon-tablecell {
display: table-cell;
vertical-align: middle;
}
<div class="col-md-4">
<div class="single-service-icon">
<div class="service-icon-container">
<div class="service-icon-tablecell">
<img src="img/service-icon-4.jpg" alt="">
</div>
</div>

<h3>Lorem ipsum dolor.</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deserunt libero, ab repudiandae incidunt dicta eveniet.</p>
</div>
</div>

最佳答案

尝试使用 CSS grid layout也可以实现相同的UI

.container {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-gap: 1em;
}

.item {
background: #ccc;
padding: 1em;
}
<div class="container">

<div class="item">
<div class="single-service-icon">
<div class="service-icon-container">
<div class="service-icon-tablecell">
<img src="img/service-icon-4.jpg" alt="">
</div>
</div>

<h3>Lorem ipsum dolor.</h3>
<p>Lorem ipsum dolor sit amet...</p>
</div>
</div>

<div class="item">
<div class="single-service-icon">
<div class="service-icon-container">
<div class="service-icon-tablecell">
<img src="img/service-icon-4.jpg" alt="">
</div>
</div>

<h3>Lorem ipsum dolor.</h3>
<p>Lorem ipsum dolor sit amet...</p>
</div>
</div>
<div class="item">
<div class="single-service-icon">
<div class="service-icon-container">
<div class="service-icon-tablecell">
<img src="img/service-icon-4.jpg" alt="">
</div>
</div>

<h3>Lorem ipsum dolor.</h3>
<p>Lorem ipsum dolor sit amet...</p>
</div>
</div>
<div class="item">
<div class="single-service-icon">
<div class="service-icon-container">
<div class="service-icon-tablecell">
<img src="img/service-icon-4.jpg" alt="">
</div>
</div>

<h3>Lorem ipsum dolor.</h3>
<p>Lorem ipsum dolor sit amet...</p>
</div>
</div>
<div class="item">
<div class="single-service-icon">
<div class="service-icon-container">
<div class="service-icon-tablecell">
<img src="img/service-icon-4.jpg" alt="">
</div>
</div>

<h3>Lorem ipsum dolor.</h3>
<p>Lorem ipsum dolor sit amet...</p>
</div>
</div>
<div class="item">
<div class="single-service-icon">
<div class="service-icon-container">
<div class="service-icon-tablecell">
<img src="img/service-icon-4.jpg" alt="">
</div>
</div>

<h3>Lorem ipsum dolor.</h3>
<p>Lorem ipsum dolor sit amet...</p>
</div>
</div>

</div>

关于html - 如何修复图标对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57128422/

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