Home >WeChat Applet >Mini Program Development >How to use local pictures as mini program background
We know that you cannot directly set local images for views in WeChat mini programs. So how do we solve this problem?
(Learning video sharing: Introduction to Programming)
The solution is as follows:
1. Use network pictures
2. Use base64 format
3. Use image to load local pictures, and then use them as interface backgrounds
The first two are very simple, let’s focus on the third one below. Generally, everyone's trouble is to put the imageview at the bottom of the interface. Then go directly to the code below.
wxml
<view class="root"> <image class='background-image' src='../res/login_bg.png' mode="aspectFill"></image> <view class="content"> </view> </view>
wxss
.root { width: 100%; height: 100%; background-color: #70c7da; position: relative; } .background-image{ height : 100%; position: absolute; width: 100%; left: 0px; top: 0px; } .content{ position: absolute; width: 100%; height: 100%; left: 0px; top: 0px; }
Okay, done. As long as you use relative layout, you can achieve it. Similar to android relative layout. Now just write all the content in content
Related recommendations:小program development tutorial
The above is the detailed content of How to use local pictures as mini program background. For more information, please follow other related articles on the PHP Chinese website!