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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

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

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Linux new version
SublimeText3 Linux latest version

Zend Studio 13.0.1
Powerful PHP integrated development environment