gpt4 book ai didi

html - float 重叠文本重叠图像

转载 作者:太空宇宙 更新时间:2023-11-04 09:11:44 25 4
gpt4 key购买 nike

在图片上,当屏幕宽度小于 1400 像素左右时,您可以看到我的文字与图像重叠的问题。

这是我的 HTML。

<article>
<img src="images/welkomartikel2.jpg" />
</article>
<aside>
<h2>Welkom</h2>
<p>The Text that overlaps</p>
</aside>

这是 CSS:

article {
float: left;
width: 50%;
margin: 0 auto;
height: auto;
padding: 4%;}

aside {
float: right;
margin: 0 auto;
width: 35%;
height: auto;
padding: 3%;}

Overlaping text on my picture

最佳答案

您将两个元素彼此相邻 float ,这样它们就永远不会重叠,但问题是您没有代码来控制图像自身 的行为方式。您需要做的是确保图像永远不会超出其父级的范围:

article img {
max-width: 100%;
max-height: 100%;
}

希望对您有所帮助! :)

关于html - float 重叠文本重叠图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42079012/

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