gpt4 book ai didi

html - 对齐 div 底部的元素

转载 作者:太空宇宙 更新时间:2023-11-03 21:18:43 24 4
gpt4 key购买 nike

我希望每个 div 的每个按钮“阅读更多”在同一级别对齐(在本例中是 div 的底部)。问题是我不想给 div 一个特定的高度,也不想更改任何标记或样式。

我可以使用一堆伪类选择器,但我希望保持代码简单,也许有更简单的方法。

Here's the working fiddle

.btn{
display: inline-block;
font-family: 'Oswald', sans-serif;
font-weight: 400px;
padding: 5px 10px;
border: 2px solid #1AC4F8;
color: #1AC4F8;
cursor: pointer;}

最佳答案

Flexbox 可以做到这一点。

它将所有列设置为相同的高度,并告诉按钮位于每列的底部。

* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
*::before,
*::after {
box-sizing: border-box;
}
.row {
display: flex;
}
#services {
background-color: rgb(265, 265, 265);
color: #424242;
}
#services .col-3 {
text-align: left;
float: none;
display: flex;
flex: 0 0 25%;
padding: 10px;
flex-direction: column;
}
#sevices h3 {
margin: 10px 0
}
.btn {
margin-top: auto;
display: inline-block;
font-family: 'Oswald', sans-serif;
font-weight: 400px;
padding: 5px 10px;
border: 2px solid #1AC4F8;
color: #1AC4F8;
cursor: pointer;
-webkit-transition: color 0.8s, background-color 0.8s;
transition: color 0.8s, background-color 0.8s
}
<section id="services">
<!-- Services Starts Here -->
<div class="wrapper">
<h2>SERVICES</h2>
<div class="divider"></div>
<div class="row">
<div class="col-3">
<h3>Consulting and audit</h3>
<p>Get help to accelerate your company online from our highly experienced specialists. It is as good as it sounds!</p>
<a href="#" class="btn">Read more</a>
</div>
<div class="col-3">
<h3>Web Development</h3>
<p>Professional custom e-commerce and web design to let your business grow at a rapid pace. See how we do that.</p>
<a href="#" class="btn">Read more</a>
</div>
<div class="col-3 right-align">
<h3>Search Engine Optimization</h3>
<p>Want to be on Page 1 of Google and Bing? Read about our SEO services that drive more potential customers.</p>
<a href="#" class="btn">Read more</a>
</div>
<div class="col-3 right-align">
<h3>Pay Per Click Management</h3>
<p>Attract highly relevant audience with Google Adwords, Display, Retargeting, Facebook, YouTube, Twitter.</p>
<a href="#" class="btn">Read more</a>
</div>
</div>
</div>
</section>

关于html - 对齐 div 底部的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39469270/

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