【发布时间】:2020-10-12 06:10:29
【问题描述】:
您好,我正在尝试在 wordpress 网站中使用 Flexbox 使两个图像高度相同。
这是我的代码:
.wrapper {
display: flex;
}
.wrapper > div:first-child {
margin-left: 15px;
}
.wrapper img{
width:150px;
}
<div class="wrapper">
<div class="img1"><img src="https://hostingstudies.com/wp-content/uploads/2020/10/wordpress-1882120_1280-3.png" />
<p>WordPress is the world’s most popular site builder. It powers more than 33% of all websites on the internet, that’s millions of websites all over the world.</p>
</div>
<div class="img2"><img src="https://hostingstudies.com/wp-content/uploads/2020/10/wordpress-923188_1280-2.jpg" />
<p>WordPress started as a simple blogging platform back in 2003. Since then it has evolved to become a content management system and an application development framework.</p>
</div>
</div>
【问题讨论】:
-
为什么不像宽度那样在 img 上固定一个固定高度?
-
但是我不想设置一个固定的高度,它会在较小的屏幕上破坏我的图像有什么方法可以使用 flexbox 吗??
-
您需要像我一样在容器中设置图像。如果你真的不能,你可能有办法使用 flex,但更复杂
标签: html css wordpress flexbox grid