当前位置:网站首页>【微信小程序】flex布局使用记录
【微信小程序】flex布局使用记录
2022-04-23 13:01:00 【许多仙】
测试代码:
1、xml:
<view class="A">
<view class="AA">AA</view>
<view class="AB">AB</view>
<view class="AC">AC</view>
</view>
2、wxss:
.A{
/**/
display: flex;/*默认排成一行*/
/*flex-direction: column;/*排列方向:row(横向正向) | row-reverse(反) | column(竖直正向) | column-reverse*/
/*flex-wrap: nowrap;/*如果是一行:如何换行排列:nowrap(不换行,默认) | wrap(正向) | wrap-reverse(反向)*/
/*flex-flow: row nowrap;/*上面两种形式的简写*/
justify-content: space-around;/*里面的内容(水平):左对齐start,end右对齐,center居中,一行时才生效(横向):between两端对齐间隔相等,around:。。。*/
align-items: flex-start;/*竖直:左对齐flex-start,..end右对齐,..center居中,baseline , stretch*//**//**//**/
/*align-content:flex-end ;/*多根轴线才起作用*/
width: 100%;
height: 100%;
background-color: rgb(223, 226, 210);
}
.AA{
width: 10%;
height: 20%;
background-color: rgb(136, 20, 20);
}
.AB{
width: 20%;
height: 20%;
background-color: rgb(52, 150, 69);
}
.AC{
width: 40%;
height: 20%;
background-color: dodgerblue;
}
3、测试结果:
其他都好说,我们重点看justify-content属性的两种(一行才起作用):
(1)space-around:均匀分布,保留两端
flex-direction: column;
justify-content: space-around;
当着两个属性同时写时,仅仅起第一个的作用,因为第二个在多行无效:
所以第二行写不写,都是下面这个样子:

如果改成横向排列(1行):(均匀排列分布)
flex-direction: row;
justify-content: space-around;

(2)space-between:均匀分布,不留两端
同理,如果是多行,则无效。
如果是一行:

另外,当我测试flex-end和center时,也是多行无效,一行有效。
如果想要多行的这两个属性生效:
4、总结:
以下列出常用的情况:
(1)一行的排列情况:
- 1、元素顺序后置:
display: flex;/*默认排成一行*/
flex-direction: row;
justify-content: flex-end;

- 2、元素倒序后置:
display: flex;/*默认排成一行*/
flex-direction: row-reverse;

- 3、紧凑居中:
display: flex;/*默认排成一行*/
flex-direction: row;
justify-content: center;

- 4、均匀分散:
justify-content:space-between:

justify-content::around:保留首尾

- 多行居中: align-items:center ;多行后置:align-items:flex-end ;


版权声明
本文为[许多仙]所创,转载请带上原文链接,感谢
https://blog.csdn.net/zhinengxiong6/article/details/124340513
边栏推荐
- CVPR 2022&NTIRE 2022|首个用于高光谱图像重建的 Transformer
- Process virtual address space partition
- How to click an object to play an animation
- SSM框架系列——数据源配置day2-1
- leetcode-791. 自定义字符串排序
- Packet capturing and sorting -- TCP protocol [8]
- Kubernetes 入門教程
- Importerror after tensorflow installation: DLL load failed: the specified module cannot be found, and the domestic installation is slow
- Get the punch in record of nailing attendance machine
- R语言中dcast 和 melt的使用 简单易懂
猜你喜欢

22. 括号生成

【蓝桥杯】4月17日省赛刷题训练(前3道题)

Wonderful review | the sixth issue of "source" - open source economy and industrial investment

Pytorch: a pit about the implementation of gradreverselayer

4.DRF 权限&访问频率&过滤&排序

数据库中的日期时间类型

About the 'enum' enumeration type and structure.

8 websites that should be known for product development to enhance work experience

SSM framework series - JUnit unit test optimization day2-3

Recovering data with MySQL binlog
随机推荐
(1) Openjuterpyrab comparison scheme
拥抱机器视觉新蓝海,冀为好望开启数字经济发展新“冀”遇
STM32 control stepper motor (ULN2003 + 28byj)
JDBC connection pool
Design of body fat detection system based on 51 single chip microcomputer (51 + OLED + hx711 + US100)
Kubernets Getting started tutoriel
Navicat远程连接数据库 出现 1130- Host xxx is not allowed to connect to this MySQL server错误
[Blue Bridge Cup] April 17 provincial competition brushing training (the first three questions)
Proteus 8.10 installation problem (personal test is stable and does not flash back!)
Date time type in database
BaseRecyclerViewAdapterHelper 实现下拉刷新和上拉加载
内核错误: No rule to make target ‘debian/canonical-certs.pem‘, needed by ‘certs/x509_certificate_list‘
CVPR 2022 & ntire 2022 | the first transformer for hyperspectral image reconstruction
World Book Day: I'd like to recommend these books
Calculate the past date and days online, and calculate the number of live days
Importerror after tensorflow installation: DLL load failed: the specified module cannot be found, and the domestic installation is slow
HQL find the maximum value in a range
Servlet监听器&过滤器介绍
Teach you to quickly develop a werewolf killing wechat applet (with source code)
Software testing weekly (issue 68): the best way to solve difficult problems is to wait and see the changes and push the boat with the current.

