gpt4 book ai didi

html - CSS - 对齐内容不影响 flex 元素

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

所以我正在处理一个小型技术挑战并使用 flexbox。我在父 div 和同一个 css 属性中设置了 display: flex; 我正在尝试使用 justify-contentspace-evenly。然而,它根本没有效果。

我的 CSS:

.relatedFlex 
{
display: flex;
background-color: #fff;
justify-content: space-between;
}

我的 HTML:

   <section class="relatedPost">
<div class="wrapper">
<h2>Related post:</h2>
<div class="relatedFlex">
<div class="relatedSectionOne">
<img class="photoWidth" src="assets/image-2.jpg" alt="Looking Stoic">
<div>
<p>MAR 9, 2019</p>
<h3>Juno Tech Test</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente quidem hic natus?</p>
<button>Read More</button>
</div>
</div>
<div class="relatedSectionTwo">
<img class="photoWidth" src="assets/image-3.jpg" alt="Hands On Learning">
<div>
<p>MAR 15, 2019</p>
<h3>Juno Tech Test</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente quidem hic natus?</p>
<button>Read More</button>
</div>
</div>
<div class="relatedSectionThree">
<img class="photoWidth" src="assets/image-3.jpg" alt="Hands On Learning">
<div>
<p>MAR 15, 2019</p>
<h3>Juno Tech Test</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente quidem hic natus?</p>
<button>Read More</button>
</div>
</div>
</div>
</div>
</section>

最佳答案

只给相关部分的宽度

.relatedFlex {
display: flex;
background-color: #fff;
justify-content: space-between;
}

.relatedSectionOne{
width:15vw;
}
   <section class="relatedPost">
<div class="wrapper">
<h2>Related post:</h2>
<div class="relatedFlex">
<div class="relatedSectionOne">
<img class="photoWidth" src="assets/image-2.jpg" alt="Looking Stoic">
<div>
<p>MAR 9, 2019</p>
<h3>Juno Tech Test</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente quidem hic natus?</p>
<button>Read More</button>
</div>
</div>
<div class="relatedSectionOne">
<img class="photoWidth" src="assets/image-3.jpg" alt="Hands On Learning">
<div>
<p>MAR 15, 2019</p>
<h3>Juno Tech Test</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente quidem hic natus?</p>
<button>Read More</button>
</div>
</div>
<div class="relatedSectionOne">
<img class="photoWidth" src="assets/image-3.jpg" alt="Hands On Learning">
<div>
<p>MAR 15, 2019</p>
<h3>Juno Tech Test</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente quidem hic natus?</p>
<button>Read More</button>
</div>
</div>
</div>
</div>
</section>

关于html - CSS - 对齐内容不影响 flex 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58983845/

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