gpt4 book ai didi

css - css div 标签中的背景图片

转载 作者:太空宇宙 更新时间:2023-11-03 23:43:20 25 4
gpt4 key购买 nike

这让我抓狂了好几个小时。请有人向我解释为什么根本没有图像出现。我正在严格使用 XHTML 1.0。非常感谢。

CSS:

#flags {
position: relative;
background-image:url(example.png);
background-repeat: no-repeat;
float: right;
margin-left: 18px;
width:400px;
height:400px;
}

HTML:

<div id="flags">
<p>text
<br />
text
<br/>
</p>

<ul>
<li>list1</li>
<li>list2</li>
<li>list3</li>
</ul>
</div>

最佳答案

当您使用 background-image 调用图像时,请确保定义了 widthheight 属性。

这是你的 CSS 代码,我添加了 heightwidth

#flags {
position: relative;
background-image:url(http://lorempixel.com/200/200);
background-repeat: no-repeat;
background-position: bottom right;
float: left;
width:100%; //width:200px; /* added the width 100% is good for responsive */
height:auto; //height:200px; /* added the height For Responsive*/
}

这是工作演示。 http://jsbin.com/lonarezu/1/edit

关于css - css div 标签中的背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22189337/

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