小程序设置背景图片

2021-06-01  本文已影响0人  HS_d119
1、直接使用http
background: url(https://XXXXXX)
2、Base64编码格式
background: url('data:image/png;base64,iVBORw0KGg');
3、定位
<!-- .wxml -->
<view class="container">
  <image class="bg" src="" />
  <view class="content">内容</view>
</view>
/* .wxss */
.container {
  position: relative;
  width: 100%;
  height: 200rpx;
}

.bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 200rpx;
}

.content {
  position: absolute;
  z-index: 1;
}
上一篇 下一篇

猜你喜欢

热点阅读