给背景图片设置,一个默认背景颜色,有以下两种方法:
<style>
.bg1{
background:url(http://debug.itxst.com/img/logo.png) red no-repeat;
height:80px;width:1000%;
}
.bg2{
background:url(http://debug.itxst.com/img/logo.png) no-repeat;
height:80px;width:1000%;
background-color:red;
}
</style>
<div class="bg1">
</div>
<div class="bg2">
</div>
本文介绍了使用CSS为背景图片设置默认颜色的两种方法。第一种方法直接将背景颜色与图片一起设置,第二种方法则单独定义了背景颜色,这两种方法都能确保在图片未加载时页面不会显得空白。

被折叠的 条评论
为什么被折叠?



