gpt4 book ai didi

html - 如何将连接在一起的两个多列 `
` 分开?

转载 作者:太空宇宙 更新时间:2023-11-04 07:23:46 28 4
gpt4 key购买 nike

这是一个JSFiddle我创建了展示代码的外观。我将如何给予这些 <div>它们之间是否存在间隙,没有一个元素低于另一个元素?

.main-content {
width: 50%;
float: left;
background: #232323;
border-radius: 50px;
padding-top: -10px;
height: 315px;
}

.main-content>h2 {
color: white;
text-align: center;
}

.ul-main>li {
display: block;
}

.related-content {
width: 50%;
float: left;
}

.video {
text-align: center;
}
<div class='main-content'>
<h2>GTR FACTS</h2>
<div class='main-list'>
<ul class='ul-main'>
<li>The GT-R is the world’s fastest accelerating production four-seater</li>
<li>It’s the fastest four-seat production car around the Nurburgring</li>
<li>Nissan GT-R engines are hand built by race engineers</li>
<li>The Nissan GT-R has near 50:50 weight distribution</li>
<li>
</li>
</ul>
</div>
</div>

<div class='related-content'>
<div class='video'>
<iframe width="560" height="315" src="https://www.youtube.com/embed/PAjD4GFi3Ko" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
</div>

最佳答案

如果您的元素保留 50% 的宽度,则它们之间将没有空格。

其中一个 div 必须小于 50% 并且使用 display: flexjustify-content: space-between 将使元素彼此分开。

检查这段代码:

.container {
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
}

.main-content {
width: 45%;
background: #232323;
border-radius: 50px;
padding-top: -10px;
height: 315px;
}

.main-content>h2 {
color: white;
text-align: center;
}

.ul-main>li {
display: block;
}

.related-content {
width: 50%;
float: left;
}

.video {
text-align: center;
}
<div class="container">
<div class='main-content'>
<h2>GTR FACTS</h2>
<div class='main-list'>
<ul class='ul-main'>
<li>The GT-R is the world’s fastest accelerating production four-seater</li>
<li>It’s the fastest four-seat production car around the Nurburgring</li>
<li>Nissan GT-R engines are hand built by race engineers</li>
<li>The Nissan GT-R has near 50:50 weight distribution</li>
<li>
</li>
</ul>
</div>
</div>

<div class='related-content'>
<div class='video'>
<iframe width="560" height="315" src="https://www.youtube.com/embed/PAjD4GFi3Ko" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
</div>
</div>

关于html - 如何将连接在一起的两个多列 `<div>` 分开?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50072253/

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