WeChat Mini Programs sets the background picture

it is not possible to use css"s background-image to set a background image for an element in WeChat Mini Programs. So I used

<image src="../../images/img.jpg"></image>
<view>absolute</view>

then use top,left,right,bottom to put the content of view on the top level of image. I want to ask if there will be a problem with this method. I can test it on my real machine (only 6s).

Mar.25,2021

there is no problem with testing the real machine in this way, but from the point of view of writing code, it is more suitable to use the background-image setting for background images

.

when using background-image, you should note that it can only use network url or base64, and local images can be tagged with image

.

set background images (previews can be displayed on mobile phones and Wechat developer tools)

<view style="background-image: url('https://segmentfault.com/img/bVbbZxX?w=1080&h=517')">absolute</view>

when using positioning, you should pay attention to locating the parent

<view class='imgbox'>
  <image class='ico' mode='scaleToFill' src='{{ico}}></image>
    <text class="txt">{{text}}</text>
</view>
.imgbox{
  position: relative;
  width: 600rpx;
  height: 400rpx;
}
.ico{
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.txt{
   position: relative;
}

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2bd39-2b242.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2bd39-2b242.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?