### [微信小程序背景图片显示不出来](https://www.prosaas.cn/article/16781) **Published:** 2020-03-26T07:55:54 **Author:** 5201314 **Excerpt:** 开发小程序的时候,设置页面的背景,用到css代码: 在调试工具上是显示的,但是扫面上传到手机上却显示不出来。这… ![](https://img.php.cn/upload/article/000/000/039/5e7c5fcbc575a453.jpg) 开发小程序的时候,设置页面的背景,用到css代码: .page\_\_bd{ width: 100%; height: 220px; background: url('../../assets/img/images.jpg') no-repeat; background-size: 100% 100%; } 在调试工具上是显示的,但是扫面上传到手机上却显示不出来。 这是由于:background-image 只能用网络url或者base64图片编码 , 本地图片只能用 image标签src属性才行。当然 image标签src属性也可以使用网络url或者base64图片编码。 解决方法: 下面通过 image 标签src属性设置,实现背景图显示 界面结构: wxss样式: .set-background { display: flex; flex-direction: column; align-items: center; height: 150px; } .set-background-avatar { width: 220px; height: 150px; } .background-content { position: absolute; z-index: 1; } .background-image { width: 225px; height: 150px; opacity: 0.8; } .post-specific-image { width: 215px; height: 150px; vertical-align: middle; } 推荐:《小程序开发教程》 以上就是微信小程序背景图片显示不出来的详细内容,更多请关注知企PROSAAS其它相关文章! **Tags:** background, css, 微信小程序 **Categories:** 后端开发 ---