【发布时间】:2016-09-16 03:13:42
【问题描述】:
我有 4 个按钮(“阅读更多”)在它们父母底部的同一级别对齐。
每一个都有不同的内容,所以为了让它们都具有相同的大小,我使用了 flexbox 和绝对定位。
现在的问题是我希望每个父母都有一个背景颜色和按钮留在里面,但他们留在外面,因为我告诉他们在每列的底部。
我有点卡住了,因为如果我删除按钮的绝对定位,父母将再次有不同的尺寸,我不希望他们有一个确定的响应式设计的高度。
.col-3 {
width: 25%;
background-color:red
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
*::before,
*::after {
box-sizing: border-box;
}
[class*="col-"] {
float: left;
}
.row::after {
content: "";
clear: both;
display: block;
}
#services {
background-color: rgb(265, 265, 265);
color: #424242;
}
#services .col-3 {
padding: 0 20px 20px;
text-align: left;
}
#services .row .col-3:first-child {
margin-left: 0
}
#services .right-align {
text-align: right;
}
#services [class^="flaticon-"]:before,
#services [class^="flaticon-"]:after,
#services [class*="flaticon-"]:before,
#services [class*="flaticon-"]:after {
font-size: 60px;
margin-left: 0;
-webkit-transition: color 0.8s;
transition: color 0.8s;
}
#services [class*="flaticon"]:hover {
color: #1AC4F8
}
#sevices h3 {
margin: 10px 0
}
.btn {
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;
}
.row {
display: flex;
flex-direction: row;
padding-bottom:40px;
}
.column {
flex: 0 0 auto;
position: relative;
}
.btn-bottom {
position: absolute;
bottom: -40px;
left: 0px;
right: 0px;
text-align:center;
}
<section id="services">
<!-- Services Starts Here -->
<div class="wrapper">
<h2>SERVICES</h2>
<div class="divider"></div>
<div class="row">
<div class="col-3 column">
<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 btn-bottom">Read more</a>
</div>
<div class="col-3 column">
<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 btn-bottom">Read more</a>
</div>
<div class="col-3 right-align column">
<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 btn-bottom">Read more</a>
</div>
<div class="col-3 right-align column">
<h3>Pay Per Click Management</h3>
<p>Attract highly relevant audience with Google Adwords, Display, Retargeting, Facebook, YouTube, Twitter.</p>
<a href="#" class="btn btn-bottom">Read more</a>
</div>
</div>
</div>
</section>
【问题讨论】:
标签: html css flexbox css-position background-color