WeChat Mini ProgramPage layout adopts Flex
Layout. Flex
layout is a new solution proposed by W3c in 2009, which can implement various page layouts in a simple, complete and responsive manner. Flex layout provides the alignment, direction and order of elements in the container, and they can even be dynamic or indefinitely sized.
The main feature of Flex layout is the ability to adjust its child elements to be used in different screen sizes. The most suitable method to fill the appropriate space
#flex layout
- Telescopic in any direction, left, right, down, up
- You can change and rearrange the order in the style layer
- Space stretching and filling of child elements
- Align along the container
- WeChat mini program implements
layout. Let’s briefly introduce the use of Flex
layout in WeChat mini program . An element whose container
has
display:flex<a href="http://www.php.cn/wiki/927.html" target="_blank"> or </a>display:block
is a flex container
(flexible container) , the child elements inside are called flex item
(flexible items), and the child elements in flex container
are laid out using Flex
.
- Specifies the block container mode, always starts displaying with a new line, the
- view
container of the WeChat applet (view, scroll-view and swiper ) are
: Specifies the in-line container mode to display child elements in one line. You can use thedispaly:block
by default.##display:flex
flex-wrap -
attribute
to specify whether it should wrap.
flex-wraphas three values:
nowrap (no line wrap),wrap(line wrap),
wrap-reverse(the first line of wrap is below)Code using display:block(default value):<view> <view>1</view> <view>2</view> <view>3</view> </view>
Display effect:
Change to
flex
You can see block
and
view
is displayed in a new line (block) or inline (
flex).
Main axis and cross axis
Flex
The flex container of the layout can be laid out in any direction.
The container has two axes by default:
main
axis) and cross axis(cross axis)
.
The starting position of the spindle is spindle starting point(main start), the end position of the spindle isspindle end point(main end), and the length of the spindle is
Spindle length(main size).
Similarly, the starting point of the cross axis is the starting point of the cross axis
(cross start), the end position is the end point of the cross axis (cross end), and the length is the length of the cross axis
(cross size). See the picture below for details:##Flex-
direction
Note,
spindle
from left to right, similarly side axis
is not necessarilyfrom top to bottom
, the direction of the main axis is flex-direction
Attribute control, it has 4 optional values: row
: The horizontal direction from left to right is the main axis
- row-reverse
: The horizontal direction from right to left is the main axis
- column
: From top The vertical direction from bottom to top is the main axis
- column-reverse
The vertical direction from bottom to top is the main axis
If The horizontal direction is the main axis, the vertical direction is the side axis, and vice versa. - Renderings of four main axis direction settings:
Example diagram
The example in the picture shows the use of different The
value is the difference in the arrangement direction. Example code:
<view> <view> <view>1</view> <view>2</view> <view>3</view> </view> <view> <view>c1</view> <view>c2</view> <view>c3</view> </view> </view>Operation effect:
flex-direction
Alignment
There are two alignment methods for child elements:
just<a href="http://www.php.cn/wiki/109.html" target="_blank">if</a>y-conent
Define the alignment of child elements on the main axisalign-items
Define the alignment of child elements on the side axis
justify-content
There are 5 optional alignment methods:
##flex-start
Spindle starting point alignment (default Value)
flex-end
Spindle end point alignment
center
Centered in the spindle Alignment
space-between
Alignment at both ends, except that the child elements at both ends are leaning towards the containers at both ends, the intervals between other child elements are equal
-
space-around
The distance between each child element is equal, and the distance between the child elements at both ends of the container is also the same as the distance between
other child elements The distance is the same. The alignment of
justify-contentis related to the direction of the main axis. In the figure below,
flex-directionis
row, and the main axis method is
from the left. Go to the rightand describe the display effect of
js<a href="http://www.php.cn/wiki/48.html" target="_blank">tify-content</a>5 values:
justify-content
align-items represents the alignment on the cross axis:
stretch
Fill the entire container (default value)
flex-start
Align the starting point of the cross axis
flex-end
Align the end of the cross axis
center
Align the center in the cross axis
baseline
Align the first line of text of the child element
align-tiems The alignment set is related to the direction of the cross-axis. The following figure is
flex-direction is
row, the side axis direction is
from top to bottom, describing the display effect of the 5 values of
align-items:
The above is the detailed content of WeChat Mini Program Flex Layout. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1
Easy-to-use and free code editor

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
