html5怎么设置整页背景图片

html-css011

html5怎么设置整页背景图片,第1张

html5加背景图片可以通过:

1.首先可以去写一个div,然后这个div当然宽高是一定要有,然后在div中去设置要的背景图片,是否重复等属性,repaet这个来设置,no-repeat(是不重复)、repeat-x(沿着x轴重复)、repeat-y(沿着Y轴重复)这里我提交一段代码:

<div id = 'test'></div>

<style>

#test{

width:300px

height:400px

background:url('图片的地址')no-repeat

}

</style>

这样背景图片就设置好了!

body{      font-family: "微软雅黑"

width: 100%

height:auto

background:url("../img/....png") no-repeat

background-size: 100%  }

在插入背景图片的容器里设置background-size: 100%,这样图片就会覆盖整页。