微信小程序背景图片设置和图片自适应宽高
我们在开发过程中经常需要对一些元素设置图片为背景图片。
网络图片:
.ServiceCenter{
width: 100vw;height: 40vw;margin-top:0.5vw ;background: url('http://www.hirelaxpalace.com/ddpk/image/ddpkxiaochengxuimg/serviceCenter01.png');
background-size:100% 100%;
-moz-background-size:100% 100%;
}
本地图片:
.ServiceCenter{
width: 100vw;height: 40vw;margin-top:0.5vw ;background: url('../../images/ddpkxiaochengxuimg/serviceCenter01.png');
background-size:100% 100%;
-moz-background-size:100% 100%;
}
在微信小程序开发环境中,用第二种方法,会报错
用第一种方法,输入网络图片地址,不会报错。