2 回答
TA贡献1788条经验 获得超4个赞
仅用于flex中心:
.apparel {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 1em;
text-align: center;
}
.shirt-name {
font-weight: 600;
display: flex;
justify-content: center;
align-items: center;
}
.price {
font-weight: 500;
}
.shirt-pic img {
width: 50px;
height: 50px;
}
<div class="apparel">
<div id="original" class="left-side">
<a class="shirt-pic" href="pages/original.html"><img src="http://placekitten.com/301/301" alt="Shirt 1" /></a>
<span class="shirt-name helvetica size-s capitalized">Original</span>
<span class="price helvetica size-s">$20.00</span>
</div>
<div id="design1" class="right-side">
<a class="shirt-pic" href="pages/design1.html"><img src="http://placekitten.com/301/301" alt="Shirt 2" /></a>
<span class="shirt-name helvetica size-s capitalized">Design 1</span>
<span class="price helvetica size-s">$30.00</span>
</div>
<div id="design2" class="left-side">
<a class="shirt-pic" href="pages/design2.html"><img src="http://placekitten.com/301/301" alt="Design 2" /></a>
<span class="shirt-name helvetica size-s capitalized">Design 2</span>
<span class="price helvetica size-s">$30.00</span>
</div>
<div id="tri-tone" class="right-side">
<a class="shirt-pic" href="pages/tri-tone.html"><img src="http://placekitten.com/301/301" alt="Tri Tone" /></a>
<span class="shirt-name helvetica size-s capitalized">Tri-Tone</span>
<span class="price helvetica size-s">$40.00</span>
</div>
</div>
TA贡献1859条经验 获得超6个赞
这只是另一种制作垂直方向的方法:
.shirt-name { font-weight: 600; display: block; }
由于span
是内联元素,因此您需要进行设置display: block
以确保下一个元素位于下一行。
- 2 回答
- 0 关注
- 112 浏览
添加回答
举报