Home WeChat Applet Mini Program Development How to set a background image when developing a small program

How to set a background image when developing a small program

Dec 29, 2020 am 09:29 AM
Applets Background picture

How to set a background image when developing a small program

Introduction:

We know that when developing WeChat applet, we cannot directly reference local images in the wxss file, otherwise the following error will occur during runtime:

(Learning video sharing: Programming video)

"Local resource images cannot be obtained through WXSS. You can use network images, or base64, or use

This article introduces how to use the tag.

Specific steps:

1. Add an tag in the wxml file:

<!--页面根标签-->
<view class="content">
	<!--pics文件夹下的background.jpg文件-->
	<image class=&#39;background&#39; src="../../pics/background.jpg" mode="aspectFill"></image>
	<!--页面其它部分-->
</view>
Copy after login

2. Add:

page{
  height:100%;
}
.background {
  width: 100%;
  height: 100%;
  position:fixed; 
  background-size:100% 100%;
  z-index: -1;
}
Copy after login
in the wxss file

It should be noted that z-index: -1 can put the picture at the bottom without affecting other parts.

(Related recommendations: 小program development tutorial)

The above is the detailed content of How to set a background image when developing a small program. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to customize background image in Win11 How to customize background image in Win11 Jun 30, 2023 pm 08:45 PM

How to customize background image in Win11? In the newly released win11 system, there are many custom functions, but many friends do not know how to use these functions. Some friends think that the background image is relatively monotonous and want to customize the background image, but don’t know how to customize the background image. If you don’t know how to define the background image, the editor has compiled the steps to customize the background image in Win11 below. If you are interested If so, take a look below! Steps for customizing background images in Win11: 1. Click the win button on the desktop and click Settings in the pop-up menu, as shown in the figure. 2. Enter the settings menu and click Personalization, as shown in the figure. 3. Enter Personalization and click on Background, as shown in the picture. 4. Enter background settings and click to browse pictures

How to delete background image in win10 personalization settings How to delete background image in win10 personalization settings Dec 21, 2023 pm 02:31 PM

Every time the desktop background used in Win10 system will be displayed in the personalized background image in the settings, some users want to delete it, but don’t know how to do it. This article is about how to delete the personalized background image in Win10 shared by this site. View used desktop background images: 1. Click [right-click] on a blank space on the desktop, and select [Personalize] in the menu item that opens; 2. In the selection image in the background, you can view the desktop backgrounds you have used. Picture; delete the used desktop background picture: Note: This operation involves modifying the registry. Modifying the registry is risky. Please back up the data in advance. 1. Press the [Win+R] key combination at the same time to open the run window and enter [regedit] ] command, and then click [OK]; 2

Develop WeChat applet using Python Develop WeChat applet using Python Jun 17, 2023 pm 06:34 PM

With the popularity of mobile Internet technology and smartphones, WeChat has become an indispensable application in people's lives. WeChat mini programs allow people to directly use mini programs to solve some simple needs without downloading and installing applications. This article will introduce how to use Python to develop WeChat applet. 1. Preparation Before using Python to develop WeChat applet, you need to install the relevant Python library. It is recommended to use the two libraries wxpy and itchat here. wxpy is a WeChat machine

Can small programs use react? Can small programs use react? Dec 29, 2022 am 11:06 AM

Mini programs can use react. How to use it: 1. Implement a renderer based on "react-reconciler" and generate a DSL; 2. Create a mini program component to parse and render DSL; 3. Install npm and execute the developer Build npm in the tool; 4. Introduce the package into your own page, and then use the API to complete the development.

Implement card flipping effects in WeChat mini programs Implement card flipping effects in WeChat mini programs Nov 21, 2023 am 10:55 AM

Implementing card flipping effects in WeChat mini programs In WeChat mini programs, implementing card flipping effects is a common animation effect that can improve user experience and the attractiveness of interface interactions. The following will introduce in detail how to implement the special effect of card flipping in the WeChat applet and provide relevant code examples. First, you need to define two card elements in the page layout file of the mini program, one for displaying the front content and one for displaying the back content. The specific sample code is as follows: &lt;!--index.wxml--&gt;&l

How to add a background image to Douyin Live Companion - How to add a background image to Douyin Live Companion How to add a background image to Douyin Live Companion - How to add a background image to Douyin Live Companion Mar 05, 2024 am 09:16 AM

Many users who live broadcast on Douyin will use the Douyin Live Companion software, but do you know how to add a background image to the Douyin Live Companion? The following is the method of adding a background image to the Douyin Live Companion brought to you by the editor. If you are interested Users, please come and take a look below. First log in to Douyin Live Companion on your computer, and then enter the homepage. On the left, we select [Add Material] under [Scene 1]. Next, there will be a window to add materials on the page. We can directly select the [Picture] function and click to enter. We will then open a window where the image material is stored locally. We need to select the picture materials we want to add and then click the Open button in the lower right corner to add them. After adding the picture, we need to use the left mouse button to drag the picture to the appropriate

How to uniformly replace ppt background images How to uniformly replace ppt background images Mar 25, 2024 pm 04:16 PM

The unified replacement of PPT background images is an important operation to improve the visual style of presentations, and can be achieved through two main methods: slide master replacement and batch replacement. Slide master replacement involves deleting the original image and inserting a new image in the master, thereby applying to all slides. The batch replacement function directly replaces the background images of all slides in the presentation. A unified background image not only enhances your presentation but also enhances your audience's focus. It is important to choose high-quality images that are consistent with the theme, and you should pay attention to adjusting details such as transparency and size. In addition, PPT also provides rich background setting options, such as gradients, textures and patterns, which can be customized according to needs.

Alipay launched the 'Chinese Character Picking-Rare Characters' mini program to collect and supplement the rare character library Alipay launched the 'Chinese Character Picking-Rare Characters' mini program to collect and supplement the rare character library Oct 31, 2023 pm 09:25 PM

According to news from this site on October 31, on May 27 this year, Ant Group announced the launch of the "Chinese Character Picking Project", and recently ushered in new progress: Alipay launched the "Chinese Character Picking-Uncommon Characters" mini program to collect collections from the society Rare characters supplement the rare character library and provide different input experiences for rare characters to help improve the rare character input method in Alipay. Currently, users can enter the "Uncommon Characters" applet by searching for keywords such as "Chinese character pick-up" and "rare characters". In the mini program, users can submit pictures of rare characters that have not been recognized and entered by the system. After confirmation, Alipay engineers will make additional entries into the font library. This website noticed that users can also experience the latest word-splitting input method in the mini program. This input method is designed for rare words with unclear pronunciation. User dismantling

See all articles