gpt4 book ai didi

javascript - 对齐元素的问题

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

我必须在每行中列出 3 个元素,这对于桌面版本来说工作正常,但在某些设备上响应不多。这些元素在 iPad 上重叠,因此当我单击元素链接时它不会打开。而且有些元素里面的文字比较长,所以我觉得这也是问题所在

我尝试过使用 display :Flex 和 Grid,但都没有用。

礼品

gift = [{ image_url ,Price of the item, Name of the gift }]

giftResults {
margin: 0 -5px;
}

.giftResults:after {
content: "";
display: table;
clear: both;
}

.error {
color: red;
}

.giftResult {
float: left;
width: 25%;
padding: 0 10px;
}

.gift-container {
width: 940px;
max-width: 100%;
min-width: 768px;
margin: 0 auto;
padding: 0 0;
padding-bottom: 3em;
}

.card {
background-color: #e5474b;
display: inline-block;
/* width: 25%; */
height: 50%;
margin-top: 30px;
width: 33.33333%;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
padding: 16px;
text-align: center;
}

.card a {
display: block;
}

.card h2 {
padding-bottom: 25px;
font-size: 20px;
height: 35px;
}

.card:hover {
height: 55%;
width: 39%;
}

@media screen and (max-width: 600px) {
.giftResult {
width: 100%;
display: block;
margin-bottom: 20px;
}
.card {
background-color: #e5474b;
max-width: 400px;
display: block;
height: 50%;
margin-top: 30px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
padding: 16px;
text-align: center;
width: fit-content;
}
}
<div className="giftResults">
<ul>{ giftDetails }
<li className="giftResult">
<div className="gift-container">
<div className="card">
<img src={props.imageUrl} alt="Item" />
<p>{`$ ${props.price}`}</p>
<a href={props.url} target="_blank" rel="noopener noreferrer">
{props.name}
</a>
</div>
</div>
</li>

</ul>
</div>

最佳答案

如果您不能使用 bootstrap,请查看下面...

/* Extra small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) {...}

/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {
/*Define the new css rules
}

/* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {...}

/* Large devices (laptops/desktops, 992px and up) */
@media only screen and (min-width: 992px) {...}

/* Extra large devices (large laptops and desktops, 1200px and up) */
@media only screen and (min-width: 1200px) {...}

关于javascript - 对齐元素的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54469784/

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