gpt4 book ai didi

html - 图像未显示在 div 中

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

尝试了 stackoverflow 中的所有解决方案,但我的 div 未显示图像:

我的 id 为:

<div id="topImage">
</div>

和风格:

#topImage{
position:absolute;
background-image:url("images/image.jpg");
background-repeat:repeat-x;
width:100%;
height: 100px;
}

Screenshot of image path.

图像在适当的位置可用。检查确认

提前致谢。

文件夹结构:

index.html
css /
-- style.css
-- images /
-- image.jpg

最佳答案

A) 在 CSS 中使用相对路径要小心。绝对路径提供更可预测的结果。

B) 此外,在没有看到其余代码的情况下,也不太清楚 div 的宽度。通过 devtools 检查它的大小或仅以 px 为单位指定确切的宽度。

试试这个方法:

#topImage {
position:absolute;
background-image:url("/css/images/image.jpg");
background-repeat:repeat-x;
width:100px;
height: 100px;
}

关于html - 图像未显示在 div 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58148579/

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