gpt4 book ai didi

html - 添加 div 后图像移出容器

转载 作者:行者123 更新时间:2023-11-28 03:49:03 24 4
gpt4 key购买 nike

所以我的网站有 3 张横跨整个宽度的图片,每张图片使用 33.33% 的宽度和固定的高度 (800px)。我想在每个单独的图像上创建淡入淡出叠加层,但是一旦我将一些 div 添加到图像的 html 代码 2,即使我没有添加任何空间,图像也会向下移动。有什么想法吗?

How it should behave

What happens upon adding new divs

这是没有任何新 div 的代码,关于如何解决这个问题有什么想法吗?

<div id="content">
<img src="images/phantom.png"alt="An image showing a male actor performing during the musical Phantom of the Opera" class="musicalimage">
<img src="images/lion_king.png" alt="An image showing a male actor performing during the musical Lion King" class="musicalimage">
<img src="images/wicked.png" alt="An image showing a female actor performing during the musical Wicked" class="musicalimage">
</div>`

#content {
height: 800px;
width: 100%;
font-size: 0px;

}

.musicalimage {
width: 33.33%;
height: 800px;
display: inline;

最佳答案

只需将 display: flex 添加到 #content

#content {
height: 800px;
width: 100%;
font-size: 0px;
display: flex;
}

.musicalimage {
width: 33.33%;
height: 800px;
display: inline;
}
<div id="content">
<img src="images/phantom.png" alt="An image showing a male actor performing during the musical Phantom of the Opera" class="musicalimage">
<img src="images/lion_king.png" alt="An image showing a male actor performing during the musical Lion King" class="musicalimage">
<img src="images/wicked.png" alt="An image showing a female actor performing during the musical Wicked" class="musicalimage">
</div>`

关于html - 添加 div 后图像移出容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43821855/

24 4 0
文章推荐: css - 如何使用模糊和盒子阴影?
文章推荐: html - 是否可以使用 css 制作 "shortcut icon"圆形?
文章推荐: javascript - 如何将我的验证函数变成 ajax 方法?
文章推荐: php - 关闭 'accordian'
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com