gpt4 book ai didi

html - float div 底部的对齐按钮

转载 作者:行者123 更新时间:2023-11-28 03:00:19 24 4
gpt4 key购买 nike

我有一个带有图 block 的概览页面,我使用 matchheight 库来动态确定行的高度。现在我想对齐 div 底部的“更多”按钮,这样它在较小的屏幕上看起来就不会像屏幕截图那样凌乱。

我尝试使用“bottom: 20px”和“left: 40%”制作按钮“position: absolute”,但这会导致响应问题。在某些分辨率下没问题,但在其他分辨率下按钮太靠右了。

我能否以一种很好的方式解决这个问题,而不必为每个分辨率使用媒体属性?

/* Block: Overview */
#overview {
padding-top: 50px;
width: 100%;
}
.overview {
text-align: center;
padding-bottom: 50px;
}
.overview img {
width: 100%;
vertical-align: middle;
padding-bottom: 30px;
}
.card-title {
text-align: center;
letter-spacing: -1px;
font-weight: 600;
font-size: 20px;
}
.card-subtitle {
margin-bottom: 0;
font-style: italic;
font-weight: 400;
font-size: 15px;
font-family: "Lora", serif;
color: #cccccc;
margin-top: -1rem;
line-height: 1.7857;
padding-bottom: 1rem;
text-align: center;
}
.btn-card {
background-color: #cccccc;
border-color: #404040;
color: #404040;
letter-spacing: 2px;
padding: 10px 20px;
horiz-align: center;
position: relative;
margin-bottom: 0;
}
.btn-card:hover {
background-color: #ffffff;
color: #404040;
border-color: #404040;
letter-spacing: 2px;
padding: 10px 20px;
}
<div class="col-sm-3 overview row-eq-height">
<div class="col-sm-12 text-center wow fadeInLeft">
<img alt="Heavy Entertainment Show" src="/images/discography/the-heavy-entertainment-show-1.jpg">
</div>
<h3 class="card-title">Heavy Entertainment Show</h3>
<h4 class="card-subtitle">November 4<sup>th</sup>, 2016</h4>
<a href="/album/the-heavy-entertainment-show/" title="Show details of Heavy Entertainment Show">
<button class="btn btn-card">MORE</button>
</a>
</div>
<div class="col-sm-3 overview row-eq-height">
<div class="col-sm-12 text-center wow fadeInLeft">
<img alt="Under the Radar Vol 1" src="/images/discography/under-the-radar-vol-1-1.jpg">
</div>
<h3 class="card-title">Under the Radar Vol 1</h3>
<h4 class="card-subtitle">December 1<sup>st</sup>, 2014</h4>
<a href="/album/under-the-radar-vol-1/" title="Show details of Under the Radar Vol 1">
<button class="btn btn-card">MORE</button>
</a>
</div>
<div class="col-sm-3 overview row-eq-height">
<div class="col-sm-12 text-center wow fadeInLeft">
<img alt="Swings Both Ways" src="/images/discography/swings-both-ways-1.jpg">
</div>
<h3 class="card-title">Swings Both Ways</h3>
<h4 class="card-subtitle">November 18<sup>th</sup>, 2013</h4>
<a href="/album/swings-both-ways/" title="Show details of Swings Both Ways">
<button class="btn btn-card">MORE</button>
</a>
</div>
<div class="col-sm-3 overview row-eq-height">
<div class="col-sm-12 text-center wow fadeInLeft">
<img alt="Take the Crown" src="/images/discography/take-the-crown-1.jpg">
</div>
<h3 class="card-title">Take the Crown</h3>
<h4 class="card-subtitle">November 2<sup>nd</sup>, 2012</h4>
<a href="/album/take-the-crown/" title="Show details of Take the Crown">
<button class="btn btn-card">MORE</button>
</a>
</div>

Overview

最佳答案

这是正确的解决方案,添加了“transform:translateX(-50%);”对齐。感谢您的帮助!

.btn-card {
background-color: #cccccc;
border-color: #404040;
color: #404040;
letter-spacing: 2px;
padding: 10px 20px;
position: absolute;
bottom: 0;
left: 50%;
transform:translateX(-50%);
margin-bottom: 20px;

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

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