有三种方式可实现在html页面种插入背景图片。1.在标签上的style属性里设置,如:
1.在对应的标签的style属性里设置,如:
<div style="background-image: url(./img/test.png)">这是一张背景图</div>
2.使用css样式的形式设置
<style type="text/css">
.bg{
background-image: url("./img/test.png");
}
</style>
<div class="bg">这是一张背景图</div>
3.使用js选择器设置
$(selector).css("background-image", url("./img/test.png"))