【发布时间】:2020-10-11 23:46:10
【问题描述】:
我尝试使用 flexbox 创建它,但是当正文副本中的文本数量不同时,我遇到了价格和 CTA 文本未与列的另一侧对齐的问题。我使用了一个网格来解决问题,但现在我似乎无法单独为列着色,而它们之间的间隙。我想如果我对 .column 类使用“背景颜色”,它会解决这个问题,但没有任何反应。任何帮助将不胜感激。 This is what I am trying to achieve
提前谢谢你。
.grid {
display: grid;
grid-gap: 25px;
margin: auto;
width: 70%;
background-color: orange;
}
.column {
display: contents;
text-align: center;
}
.title {
grid-row-start: 1;
}
.body {
grid-row-start: 2;
}
.price {
grid-row-start: 3;
}
.cta {
grid-row-start: 4;
}
<div class="grid">
<div class="column">
<div class="title">
<h2> GOLD MEMBERSHIP</h2>
</div>
<div class="body">
<p>-For anyone who wants a better deal</p>
<p>-Benefits</p>
<p>-And other benefits</p>
</div>
<div class="price">
<p>$0 Membership Fee</p>
</div>
<div class="cta">
<p>JOIN NOW</p>
</div>
</div>
<div class="column">
<div class="title">
<h2>REGULAR MEMBERSHIP</h2>
</div>
<div class="body">
<p>-For anyone who just wants the benefits of the buying group and imma add some more text to test if it will keep on aligning even with unequal text length to mess with the text length and on and on and on and whatnot</p>
<p>-Benefits</p>
<p>-And other benefits</p>
</div>
<div class="price">
<p>$150 Membership Fee</p>
</div>
<div class="cta">
<p>JOIN NOW</p>
</div>
</div>
</div>
【问题讨论】: