gpt4 book ai didi

html - 为什么叠加的图片和标志+文字不起作用?

转载 作者:行者123 更新时间:2023-12-04 08:41:37 24 4
gpt4 key购买 nike

我必须将 Logo 的分辨率更改为至少能够看到 Logo (格式为 3400x1716)到 99x50 以重叠图片并添加带有 Logo 的文本。
我将应该叠加的图片设置为 300 高度和 100% 宽度以填充页面的其余部分,但这在我的代码中显示。
最终产品将是我将能够将鼠标悬停在图片/ Logo 上并显示文本。
我的问题是我看不到 Logo ,也看不到应该叠加图片的文字。
总共有 12 张图片,有 12 种不同的文字,但标志相同。

.portfolio-items-wrapper {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}

.portfolio-item-wrapper {
position: relative;
}

.portfolio-img-background {
height: 300px;
width: 100%;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}

.img-text-wrapper {
position: absolute;
top: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100%;
text-align: center;
padding-left: 100%;
padding-right: 100%;
}
<div class="content-wrapper">
<div class="portfolio-items-wrapper">
<div class="portfolio-item-wrapper">
<div class="portfolio-img-background" style="background- image:url(images/portfolio1.jpg)"></div>
<div class="img-text-wrapper">
<div class="logo-wrapper">
<img src="images/logos/thought.png">
</div>
<div class="subtitle">
Using a different approach than the NORM!
</div>
</div>
</div>
<div class="portfolio-item-wrapper">
<div class="portfolio-img-background" style="background- image:url(images/portfolio2.jpg)"></div>

<div class="img-text-wrapper">
<div class="logo-wrapper">
<img src="images/logos/thought.png">
</div>

<div class="subtitle">
Everything starts with a THOUGHT!
</div>
</div>
</div>
</div>
</div>

最佳答案

您可以使用您开始使用的方法,即为您的父容器元素设置背景图像,然后您可以使用 flexbox 定位文本和 Logo 元素。

img {
width:50px;height:50px;
}

div {
background-image:url('https://static-cse.canva.com/image/1578/RoyalBlue_Set1_23.5dfc6872.png');
background-size:contain;
background-repeat:no-repeat;
background-position:center center;
width:300px;height:300px;
display:flex;align-items:center;flex-direction:column;justify-content:center;
color:#FFF;font-size:36px;
}
<div>
<img src="https://assets.codepen.io/5200861/internal/avatars/users/default.png">
<h3>some text here</h3>
</div>

关于html - 为什么叠加的图片和标志+文字不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64542369/

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