gpt4 book ai didi

html - 移动设备上从 4 到 3 的卡片网格?

转载 作者:行者123 更新时间:2023-12-04 08:36:19 25 4
gpt4 key购买 nike

我需要转换我的卡片网格,所以在移动设备上它只适合移动设备宽度的 3,但在台式机和平板电脑上适合 4。
现在我有这个:
enter image description here
但不会正确调整大小,所以我不能使屏幕更窄(到移动设备大小):
enter image description here
码笔 :
https://codepen.io/ogonzales/pen/abNQXLg
HTML 代码 :

<div class="row">
<p> Just spacing</p>
</div>
<div class="row">
<div class="col-md-8">

<section id="team">
<div class="container">
<div class="grid">

<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<img src="https://cdn.shopify.com/s/files/1/0408/5792/7834/files/08_Dota_2_140x175.jpg" alt="Avatar"
style="width:120px;height:120px;" />
</div>
<div class="flip-card-back">
<br />
<p>WR : 50%</p>
<p>PR : 50%</p>
</div>
</div>
</div>
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<img src="https://cdn.shopify.com/s/files/1/0408/5792/7834/files/08_Dota_2_140x175.jpg" alt="Avatar"
style="width:120px;height:120px;" />
</div>
<div class="flip-card-back">
<br />
<p>WR : 50%</p>
<p>PR : 50%</p>
</div>
</div>
</div><div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<img src="https://cdn.shopify.com/s/files/1/0408/5792/7834/files/08_Dota_2_140x175.jpg" alt="Avatar"
style="width:120px;height:120px;" />
</div>
<div class="flip-card-back">
<br />
<p>WR : 50%</p>
<p>PR : 50%</p>
</div>
</div>
</div>
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<img src="https://cdn.shopify.com/s/files/1/0408/5792/7834/files/08_Dota_2_140x175.jpg" alt="Avatar"
style="width:120px;height:120px;" />
</div>
<div class="flip-card-back">
<br />
<p>WR : 50%</p>
<p>PR : 50%</p>
</div>
</div>
</div>
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<img src="https://cdn.shopify.com/s/files/1/0408/5792/7834/files/08_Dota_2_140x175.jpg" alt="Avatar"
style="width:120px;height:120px;" />
</div>
<div class="flip-card-back">
<br />
<p>WR : 50%</p>
<p>PR : 50%</p>
</div>
</div>
</div>
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<img src="https://cdn.shopify.com/s/files/1/0408/5792/7834/files/08_Dota_2_140x175.jpg" alt="Avatar"
style="width:120px;height:120px;" />
</div>
<div class="flip-card-back">
<br />
<p>WR : 50%</p>
<p>PR : 50%</p>
</div>
</div>
</div>
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<img src="https://cdn.shopify.com/s/files/1/0408/5792/7834/files/08_Dota_2_140x175.jpg" alt="Avatar"
style="width:120px;height:120px;" />
</div>
<div class="flip-card-back">
<br />
<p>WR : 50%</p>
<p>PR : 50%</p>
</div>
</div>
</div>
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<img src="https://cdn.shopify.com/s/files/1/0408/5792/7834/files/08_Dota_2_140x175.jpg" alt="Avatar"
style="width:120px;height:120px;" />
</div>
<div class="flip-card-back">
<br />
<p>WR : 50%</p>
<p>PR : 50%</p>
</div>
</div>
</div>
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<img src="https://cdn.shopify.com/s/files/1/0408/5792/7834/files/08_Dota_2_140x175.jpg" alt="Avatar"
style="width:120px;height:120px;" />
</div>
<div class="flip-card-back">
<br />
<p>WR : 50%</p>
<p>PR : 50%</p>
</div>
</div>
</div>
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<img src="https://cdn.shopify.com/s/files/1/0408/5792/7834/files/08_Dota_2_140x175.jpg" alt="Avatar"
style="width:120px;height:120px;" />
</div>
<div class="flip-card-back">
<br />
<p>WR : 50%</p>
<p>PR : 50%</p>
</div>
</div>
</div>
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<img src="https://cdn.shopify.com/s/files/1/0408/5792/7834/files/08_Dota_2_140x175.jpg" alt="Avatar"
style="width:120px;height:120px;" />
</div>
<div class="flip-card-back">
<br />
<p>WR : 50%</p>
<p>PR : 50%</p>
</div>
</div>
</div>
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<img src="https://cdn.shopify.com/s/files/1/0408/5792/7834/files/08_Dota_2_140x175.jpg" alt="Avatar"
style="width:120px;height:120px;" />
</div>
<div class="flip-card-back">
<br />
<p>WR : 50%</p>
<p>PR : 50%</p>
</div>
</div>
</div>


</div>
</div>
</section>

</div>
<div class="col-md-4">
<div class="row">
<div class="__range __range-step __range-step-popup">
<input value="1" type="range" max="4" min="1" step="1" list="ticks2">
<datalist id="ticks2">
<option value="1">Very bad</option>
<option value="2">Bad</option>
<option value="3">Good</option>
<option value="4">Excellent</option>
</datalist>
<output class="__range-output-square"></output>
</div>
</div>
<div class="row">
<div class="form-check">
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value="option1"
checked>
<label class="form-check-label" for="exampleRadios1">
Default radio
</label>
</div>
</div>
<div class="row">
<div class="form-check">
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios2" value="option2">
<label class="form-check-label" for="exampleRadios2">
Second default radio
</label>
</div>
</div>
<div class="row">
<div class="form-check">
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios3" value="option3"
disabled>
<label class="form-check-label" for="exampleRadios3">
Disabled radio
</label>
</div>
</div>
</div>
</div>
更新 1:
使用建议的媒体查询,不起作用:
enter image description here
代码编辑:
 /* Tablets */
@media(max-width: 768px) {
.grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
justify-items: center;
align-items: center;
grid-gap: 15px;
}
}

/* Mobile */
@media(max-width: 500px) {
.grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
justify-items: center;
align-items: center;
grid-gap: 15px;
}
}

最佳答案

尝试使用媒体查询来实现您想要的结果。

<!-- Tablets -->
@media(max-width: 768px) {
.grid {
grid-template-columns: repeat(3, 1fr);
}
}

<!-- Mobile -->
@media(max-width: 500px) {
.grid {
grid-template-columns: repeat(3, 1fr);
}
}
这就是你最终的 CSS 的样子
   .grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
justify-items: center;
align-items: center;
grid-gap: 15px;
}

.flip-card {
border-style: hidden;
background-color: transparent;
width: 120px;
height: 120px;
perspective: 1000px;
}

.flip-card-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.6s;
transform-style: preserve-3d;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}

.flip-card:hover .flip-card-inner {
transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
}

.flip-card-front {
background-color: #bbb;
color: black;
}

.flip-card-back {
background-color: #222e36ef;
color: white;
transform: rotateY(180deg);
}

@media(max-width: 768px) {
.grid {
grid-template-columns: repeat(3, 1fr);
}
}

@media(max-width: 500px) {
.grid {
grid-template-columns: repeat(3, 1fr);
}
}
Tablet view works
Mobile view works

关于html - 移动设备上从 4 到 3 的卡片网格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64779102/

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