亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home WeChat Applet Mini Program Development How should WeChat mini programs be laid out?

How should WeChat mini programs be laid out?

Jun 05, 2018 pm 02:03 PM
WeChat

1: Flex layout

Flex layout is shown in Figure 1

Figure 1

1.1 Flex container properties

##1.2 Flex Element attributes in the container

If aligned is defined, it will overwrite the attributes set by justify-content and align-items in the container attributes

In the WeChat applet development project, create a new file layout, and then create various files (named after layout),

in layout.wxml Add the following code:

<view class="container1">
?<view class="item1">
?1
?</view>
<view class="item1">
?2
?</view>
?<view class="item1">
?3
?</view>
?<view class="item1">
?4
?</view>
</view>

Add the following code to layout.wxss:

.container1{
????height:?100%;
????width:100%;
????background-color:beige;
}
.item1{
????height:100rpx;
????width:100rpx;
????background-color:cyan;
????border:?1px?solid?#fff
}

Compile and run as shown in Figure 2

Note: In the above code, 4 sub-elements view(item1) are added to the container1 container. In the style file of item1, the width and height of each item1 are set to a fixed value: 100rpx, rpx is the same as the screen size. The relevant scaling unit is different from the fixed px. The side of each item1 is 1px, solid line (soliod), white (#fff)

Figure 2

Modify .container1 as follows: (Add display:flex;) Compile and run as shown in Figure 3: It can be seen that the flex layout is the default horizontal arrangement of elements

.container1{
????height:?100%;
????width:100%;
????background-color:beige;
????display:flex;
}

Figure 3

##1.1.1 Container properties: flex-direction

Add the following code to .container1: Set the flex layout to arrange the elements vertically (from left to right as the cross axis, from top to bottom as the main axis), as shown in Figure 2. (row: flex layout arranges elements horizontally --- from left to right as the main axis, from top to bottom as the cross axis)

?flex-direction:column

1.1.2 Container attributes: flex- wrap

Add the following code to .container1: At the same time, copy the element code in layout.wxml to the 8 element views, compile and run, the effect is shown in Figure 4, you can see The original height and width are 100rpx, and the square view has been transformed into a rectangle.

flex-wrap:nowrap

Figure 4

If modified to the following code: Compile and run as shown in Figure 5: Make sure that each subview is a square, and then put the 8th subview that cannot fit into the next row

flex-wrap:wrap

##Figure 5

1.1.3容器屬性:?
flex-flow
flex-flow: wrap row,

Compile and run results: As shown in Figure 5, flex-flow is equivalent to flex-direction The combination of the two attributes with flex-wrap

1.1.4容器屬性:justify-content
Add the following code to .container1: Compile and run as shown in Figure 6. Indicates the alignment on the main axis. Since we set

flex-flow: wrap row---

in the above code, it is equivalent to the main axis being from left to right, so the 8th element that cannot be displayed on one line is displayed in the center of the next line. , and the first seven subviews are also displayed in the middle of a row, with blank margins on the left and right sides

justify-content:center

Figure 6

justify-content:flex-end?(主軸為左到右情況下:右對(duì)齊)

編譯運(yùn)行效果如圖7所示:

圖7

justify-content:flex-start?(主軸為左到右情況下:左對(duì)齊)不舉例顯示了
justify-content:space-around---效果如圖8所示,每個(gè)子view左右都有留邊

圖8

justify-content:space-between---
效果如圖9所示,每個(gè)子view左右都有留邊,但是首尾兩個(gè)view各自左右對(duì)齊不留邊


圖9

1.1.5容器屬性:align-items

上面已經(jīng)很詳細(xì)講解主軸上的對(duì)齊方式,這里關(guān)于這個(gè)交叉軸上的對(duì)齊方式同理很簡(jiǎn)單,就不詳細(xì)展開了。

1.2.1?容器內(nèi)元素屬性:flex-grow

layout.wxml中修改代碼如下:增加i3

?<view class="item1 i3">
?3
?</view>

layout.wxss中修改代碼如下:在item1中增加:? flex-grow: 1,增加i3,表示在一行中如果有剩余空間的話,i3之外的子view占1份空間,而i3子view占2份空間,編譯運(yùn)行效果如圖10所示:可以看出i3view所占據(jù)的空間比其余3個(gè)子view大,但是沒有到2倍

.item1{
????height:100rpx;
????width:100rpx;
????background-color:cyan;
????border:?1px?solid?#fff;
????flex-grow:?1
}
.i3{
????flex-grow:?2
}

圖10

1.2.2容器內(nèi)元素屬性:flex-shrink

layout.wxml再增加4個(gè)子view

layout.wxss中修改代碼如下:i3的flex-shrink為0,其余子view為1,這表示當(dāng)空間不足時(shí)所有子view都等比縮小,但是i3的view保持大小不變,編譯運(yùn)行,效果如圖11所示

.item1{
????height:100rpx;
????width:100rpx;
????background-color:cyan;
????border:?1px?solid?#fff;
????flex-shrink:?1
}
.i3{
????flex-shrink:?0
}

圖11

1.2.3容器內(nèi)元素屬性:
flex-basis

layout.wxss中修改代碼如下:其他代碼保持不變不變,編譯運(yùn)行,效果如圖12所示

.i3{????flex-shrink:?0;????flex-basis:?200rpx
}

圖12

1.2.4容器內(nèi)元素屬性:
flex

flex是grow,shink,basis幾個(gè)屬性的合并,layout.wxss中修改代碼如下:其他代碼保持不變不變,編譯運(yùn)行,效果和圖12保持一樣

.i3{????flex:0?0?200rpx}
1.2.5容器內(nèi)元素屬性:order

layout.wxml中修改代碼如下:設(shè)置每個(gè)view的order屬性為其顯示的順序,編譯運(yùn)行

<view class="container1">
?<view class="item1" style="order:4">
?1
?</view>
<view class="item1" style="order:3">
?2
?</view>
?<view class="item1 i3" style="order:2">
?3
?</view>
?<view class="item1" style="order:1">
?4
?</view>
</view>

相信看了本文案例你已經(jīng)掌握了方法,更多精彩請(qǐng)關(guān)注php中文網(wǎng)其它相關(guān)文章!

推薦閱讀:

微信小程序開發(fā)中怎樣實(shí)現(xiàn)地址頁(yè)面三級(jí)聯(lián)動(dòng)

新手怎樣開發(fā)第一款微信小程序

The above is the detailed content of How should WeChat mini programs be laid out?. 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

Undress AI Tool

Undress AI Tool

Undress images for free

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.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

Hot Topics

PHP Tutorial
1488
72
TikTok web version entrance login link address https TikTok web version entrance website free TikTok web version entrance login link address https TikTok web version entrance website free May 22, 2025 pm 04:24 PM

The login portal for the Douyin web version is https://www.douyin.com/. The login steps include: 1. Open the browser; 2. Enter the URL https://www.douyin.com/; 3. Click the "Login" button and select the login method; 4. Enter the account password; 5. Complete login. The web version provides functions such as browsing, searching, interaction, uploading videos and personal homepage management, and has advantages such as large-screen experience, multi-tasking, convenient account management and data statistics.

Are these C2C transactions in Binance risky? Are these C2C transactions in Binance risky? Apr 30, 2025 pm 06:54 PM

Binance C2C transactions allow users to buy and sell cryptocurrencies directly, and pay attention to the risks of counterparty, payment and price fluctuations. Choosing high-credit users and secure payment methods can reduce risks.

Copy comics (official website entrance)_Copy comics (nba) genuine online reading portal Copy comics (official website entrance)_Copy comics (nba) genuine online reading portal Jun 05, 2025 pm 04:12 PM

Copying comics is undoubtedly a treasure that cannot be missed. Here you can find basketball comics in various styles, from passionate and inspiring competitive stories to relaxed and humorous daily comedy. Whether you want to relive the classics or discover new works, copying comics can meet your needs. Through the authentic online reading portal provided by copy comics, you will bid farewell to the trouble of pirated resources, enjoy a high-definition and smooth reading experience, and can support your favorite comic authors and contribute to the development of authentic comics.

Which is better, uc browser or qq browser? In-depth comparison and evaluation of uc and qq browsers Which is better, uc browser or qq browser? In-depth comparison and evaluation of uc and qq browsers May 22, 2025 pm 08:33 PM

Choosing UC browser or QQ browser depends on your needs: 1. UC browser is suitable for users who pursue fast loading and rich entertainment functions; 2. QQ browser is suitable for users who need stability and seamless connection with Tencent products.

Top 10 AI writing software rankings Recommended Which AI writing software is free Top 10 AI writing software rankings Recommended Which AI writing software is free Jun 04, 2025 pm 03:27 PM

Combining the latest industry trends and multi-dimensional evaluation data in 2025, the following are the top ten comprehensive AI writing software recommendations, covering mainstream scenarios such as general creation, academic research, and commercial marketing, while taking into account Chinese optimization and localization services:

Watch the official page of NIS comics online for free comics. The free entry website of NIS comics login page Watch the official page of NIS comics online for free comics. The free entry website of NIS comics login page Jun 12, 2025 pm 08:18 PM

Nice Comics, an immersive reading experience platform dedicated to creating for comic lovers, brings together a large number of high-quality comic resources at home and abroad. It is not only a comic reading platform, but also a community that connects comic artists and readers and shares comic culture. Through simple and intuitive interface design and powerful search functions, NES Comics allows you to easily find your favorite works and enjoy a smooth and comfortable reading experience. Say goodbye to the long waiting and tedious operations, enter the world of Nice comics immediately and start your comic journey!

Frog Man Online Viewing Entrance Man Frog Man (Web Page Entrance) Watch Online Frog Man Online Viewing Entrance Man Frog Man (Web Page Entrance) Watch Online Jun 12, 2025 pm 08:06 PM

Frogman Comics has become the first choice for many comic lovers with its rich and diverse comic resources and convenient and smooth online reading experience. It is like a vibrant pond, with fresh and interesting stories constantly emerging, waiting for you to discover and explore. Frog Man comics cover a variety of subjects, from passionate adventures to sweet love, from fantasy and science fiction to suspense reasoning, no matter which genre you like, you can find your favorite works here. Its simple and intuitive interface design allows you to easily get started, quickly find the comics you want to read, and immerse yourself in the exciting comic world.

Baozi Comics (Entrance)_ Baozi Comics (New Entrance) 2025 Baozi Comics (Entrance)_ Baozi Comics (New Entrance) 2025 Jun 05, 2025 pm 04:18 PM

Here, you can enjoy the vast ocean of comics and explore works of various themes and styles, from passionate young man comics to delicate and moving girl comics, from suspenseful and brain-burning mystery comics to relaxed and funny daily comics, there is everything, and there is always one that can touch your heartstrings. We not only have a large amount of genuine comic resources, but also constantly introduce and update the latest works to ensure that you can read your favorite comics as soon as possible.

See all articles