css background 设置不了背景图片
我自己在给div设置背景图片时,代码如下
.bg{
.bg{
background: url(./bg1.jpg) no-repeat 0 0;
}
.content{
font-size: 26px;
font-weight: bold;
/* color: rgba(0 , 10, 10, 1); */
color: red;
}
}
<div class="bg"></div>
<div class="content">
Hello World
</div>
发现效果如图
怎么也显示不了图片
我发现我的图片地址也没有问题,最后检擦代码,发现时没有给div设置宽高原因导致的
.bg{
width:100px;
height: 100px;
background: url(./bg1.jpg) no-repeat 0 0;
}
最后完美解决问题