gpt4 book ai didi

html - 4 'div' s 不能水平对齐

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

问题是我想让 4 个盒子像卡片一样水平对齐,但结果像楼梯,请帮忙

有 99 行所以请访问这里 jsfiddle

                #first {
display: flex;
justify-content: center;
margin-left:10px;
margin-top:20px;
}

最佳答案

请试试这个 DEMO

从 css 中删除 first、second、third 和 fourth...nth,在 .card-container 下方添加这些

.card-container {
float: left;
width: calc(100%/4);
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
align-items: baseline;
align-content: center;
}

body {
font-family:Arial, Helvetica, sans-serif;
font-size:36px;
}
h1 {
margin:0;
}

.card-container {
perspective:700;
}
.card {
position:relative;
color:white;
text-align:center;
line-height:200px;
margin:20px;
width:200px;
height:200px;
transition:all 0.6s ease;
transform-style:preserve-3d;
}
.front, .back {
background-color:#5677fc;
position:absolute;
top:0;
left:0;
width:200px;
height:600px;
backface-visibility:hidden;
}
.back {
transform:rotateY(180deg);
}
.card:hover {
transform:rotateY(180deg);
}
.card-container {
float: left;
width: calc(100%/4);
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
align-items: baseline;
align-content: center;
}
<body>
<div class="card-container" id="first">
<div class="card">
<div class="front"><h1>hello</h1></div>
<div class="back"><h1>Goodbye</h1></div>
</div>
</div>

<div class="card-container" id="second">
<div class="card">
<div class="front"><h1>hello</h1></div>
<div class="back"><h1>Goodbye</h1></div>
</div>
</div>

<div class="card-container" id="third">
<div class="card">
<div class="front"><h1>hello</h1></div>
<div class="back"><h1>Goodbye</h1></div>
</div>
</div>

<div class="card-container" id="forth">
<div class="card">
<div class="front"><h1>hello</h1></div>
<div class="back"><h1>Goodbye</h1></div>
</div>
</div>
</body>

关于html - 4 'div' s 不能水平对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45413711/

25 4 0
文章推荐: html - 将宽度为 100% 的
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com