【发布时间】:2021-10-06 09:58:04
【问题描述】:
我正在尝试调整在 google 上搜索的网格中第一列的大小,但找不到解决方案。 我可以用 css 做到这一点,但想学习如何调整网格中重复列的大小。
我希望第一张卡片是 width: 50%; 和另外两张卡片 width:25%; 和 width:25%;
这是我的代码
.slider-cards {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 20px;
margin-bottom: 40px;
}
.slider-cards img {
width: 100%;
margin-bottom: 20px;
}
.slider-cards h3 {
margin-bottom: 5px;
}
.slider-cards a {
display: inline-block;
padding-top: 10px;
color: #0067b8;
text-transform: uppercase;
font-weight: bold;
}
.slider-cards a:hover i {
margin-left: 10px;
}
<div class="slider-cards">
<div class="first">
<img src="https://i.ibb.co/LZPVKq9/card1.png" alt="">
<h3>The Conversation has reported</h3>
<p>
COVID-19 has had a deeply unequal impact on UK society, affecting some communities substantially more than others.
</p>
<a href="#">Learn More <i class="fas fa-chevron-right"></i></a>
</div>
<div class="second">
<img src="https://i.ibb.co/LZPVKq9/card1.png" alt="">
<h3>The Conversation has reported</h3>
<p>
COVID-19 has had a deeply unequal impact on UK society, affecting some communities substantially more than others.
</p>
<a href="#">Learn More <i class="fas fa-chevron-right"></i></a>
</div>
<div class="third">
<img src="https://i.ibb.co/LZPVKq9/card1.png" alt="">
<h3>The Conversation has reported</h3>
<p>
COVID-19 has had a deeply unequal impact on UK society, affecting some communities substantially more than others.
</p>
<a href="#">Learn More <i class="fas fa-chevron-right"></i></a>
</div>
</div>
:
【问题讨论】:
-
设置每列的宽度
grid-template-columns: 50% 25% 25%;