微信小程序组件解读和分析:一、view(视图容器 )
view组件说明:
视图容器
跟HTML代码中的DIV一样,可以包裹其他的组件,也可以被包裹在其他的组件内部。用起来比较自由随意,没有固定的结构。
view组件的用法:

示例项目的wxml代码:
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<view class="btnGroup"> <view class="item orange" >退格</view> <view class="item orange" >清屏</view> <view class="item orange" >+/-</view> <view class="item orange" >+</view> </view> <view class="btnGroup"> <view class="item blue" >9</view> <view class="item blue" >8</view> <view class="item blue" >7</view> <view class="item orange" >-</view> </view> <view class="btnGroup"> <view class="item blue" >6</view> <view class="item blue" >5</view> <view class="item blue" >4</view> <view class="item orange" >×</view> </view> <view class="btnGroup"> <view class="item blue" >3</view> <view class="item blue" >2</view> <view class="item blue" >1</view> <view class="item orange" >÷</view> </view> <view class="btnGroup"> <view class="item blue" >0</view> <view class="item blue" >.</view> <view class="item blue" >历史</view> <view class="item orange" >=</view> </view> |
示例项目的WXSS代码:
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
|
.btnGroup{ display:flex; flex-direction:row;}.orange{ color: #fef4e9; border: solid 1px #da7c0c; background: #f78d1d;}.blue{ color: #d9eef7; border: solid 1px #0076a3; background: #0095cd;} |
视图样式flex-direction: row的效果图:
WXML代码如下
|
1
2
3
4
5
|
<view class="flex-wrp"> <view class="flex-item red" ></view> <view class="flex-item green" ></view> <view class="flex-item blue" ></view></view> |
WXSS代码如下:
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
|
.flex-wrp{ height: 100px; display:flex; background-color: #FFFFFF;}.flex-item{ width: 100px; height: 100px;}.red{ background: red;}.green{ background: green;}.blue{ background: blue;} |
视图样式flex-direction: column的效果图:
WXML代码如下:
|
1
2
3
4
5
|
<view class="flex-wrp column"> <view class="flex-item" style="background: red"></view> <view class="flex-item" style="background: green"></view> <view class="flex-item" style="background: blue"></view></view> |
WXSS代码如下:
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
|
.column{ flex-direction:column;}.flex-item{ width: 100px; height: 100px;}.flex-wrp{ height: 100px; display:flex; background-color: #FFFFFF;}.red{ background: red;}.green{ background: green;}.blue{ background: blue;} |
视图样式justify-content: flex-start的效果图:
WXML代码如下:
|
1
2
3
4
5
|
<view class="flex-wrp flex-start"> <view class="flex-item" style="background: red"></view> <view class="flex-item" style="background: green"></view> <view class="flex-item" style="background: blue"></view></view> |
WXSS代码如下:
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
|
.flex-start{ flex-direction:row; justify-content: flex-start;}.flex-wrp{ height: 100px; display:flex; background-color: #FFFFFF;}.flex-item{ width: 100px; height: 100px;}.red{ background: red;}.green{ background: green;}.blue{ background: blue;} |
视图样式justify-content: flex-end的效果图:
WXML代码如下:
|
1
2
3
4
5
|
<view class="flex-wrp flex-end"> <view class="flex-item" style="background: red"></view> <view class="flex-item" style="background: green"></view> <view class="flex-item" style="background: blue"></view></view> |
WXSS代码如下:
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
|
.flex-end{ flex-direction:row; justify-content: flex-end;}.flex-wrp{ height: 100px; display:flex; background-color: #FFFFFF;}.flex-item{ width: 100px; height: 100px;}.red{ background: red;}.green{ background: green;}.blue{ background: blue;} |
视图样式justify-content: center的效果图:
WXML代码如下:
|
1
2
3
4
5
|
<view class="flex-wrp justify-content-center"> <view class="flex-item" style="background: red"></view> <view class="flex-item" style="background: green"></view> <view class="flex-item" style="background: blue"></view></view> |
WXSS代码如下:
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
|
.justify-content-center{ flex-direction:row; justify-content: center;}.flex-wrp{ height: 100px; display:flex; background-color: #FFFFFF;}.flex-item{ width: 100px; height: 100px;}.red{ background: red;}.green{ background: green;}.blue{ background: blue;} |
视图样式justify-content: space-between的效果图:
WXML代码如下:
|
1
2
3
4
5
|
<view class="flex-wrp space-between"> <view class="flex-item" style="background: red"></view> <view class="flex-item" style="background: green"></view> <view class="flex-item" style="background: blue"></view></view> |
WXSS代码如下:
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
|
.space-between{ flex-direction:row; justify-content: space-between;}.flex-wrp{ height: 100px; display:flex; background-color: #FFFFFF;}.flex-item{ width: 100px; height: 100px;}.red{ background: red;}.green{ background: green;}.blue{ background: blue;} |
视图样式justify-content: space-around的效果图:
WXML代码如下:
|
1
2
3
4
5
|
<view class="flex-wrp space-around"> <view class="flex-item" style="background: red"></view> <view class="flex-item" style="background: green"></view> <view class="flex-item" style="background: blue"></view></view> |
WXSS代码如下:
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
|
.space-around{ flex-direction:row; justify-content: space-around;}.flex-wrp{ height: 100px; display:flex; background-color: #FFFFFF;}.flex-item{ width: 100px; height: 100px;}.red{ background: red;}.green{ background: green;}.blue{ background: blue;} |
视图样式align-items: flex-end的效果图:
WXML代码如下:
|
1
2
3
4
5
|
<view class="flex-wrp align-items-flex-end"> <view class="flex-item" style="background: red"></view> <view class="flex-item" style="background: green"></view> <view class="flex-item" style="background: blue"></view></view> |
WXSS代码如下:
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
.align-items-flex-end{ height: 200px; flex-direction:row; justify-content: center; align-items: flex-end;}.flex-wrp{ height: 100px; display:flex; background-color: #FFFFFF;}.flex-item{ width: 100px; height: 100px;}.red{ background: red;}.green{ background: green;}.blue{ background: blue;} |
视图样式align-items: center的效果图:
WXML代码如下:
|
1
2
3
4
5
|
<view class="flex-wrp align-items-center"> <view class="flex-item" style="background: red"></view> <view class="flex-item" style="background: green"></view> <view class="flex-item" style="background: blue"></view></view> |
WXSS代码如下:
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
.align-items-center{ height: 200px; flex-direction:row; justify-content: center; align-items: center;}.flex-wrp{ height: 100px; display:flex; background-color: #FFFFFF;}.flex-item{ width: 100px; height: 100px;}.red{ background: red;}.green{ background: green;}.blue{ background: blue;} |
视图样式align-items: flex-start的效果图:
WXML代码如下:
|
1
2
3
4
5
|
<view class="flex-wrp align-items-flex-start"> <view class="flex-item" style="background: red"></view> <view class="flex-item" style="background: green"></view> <view class="flex-item" style="background: blue"></view></view> |
WXSS代码如下:
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
.align-items-flex-start{ height: 200px; flex-direction:row; justify-content: center; align-items: flex-start;}.flex-wrp{ height: 100px; display:flex; background-color: #FFFFFF;}.flex-item{ width: 100px; height: 100px;}.red{ background: red;}.green{ background: green;}.blue{ background: blue;} |
排列方式(flex-direction),用于wxss
|
属性
|
描述
|
|
row
|
横向排列
|
|
column
|
纵向排列
|
弹性项目内容对齐(justify-content),用于wxss
|
属性
|
描述
|
|
flex-start
|
弹性项目向行头紧挨着填充
|
|
flex-end
|
弹性项目向行尾紧挨着填充
|
|
center
|
弹性项目居中紧挨着填充
|
|
space-between
|
弹性项目平均分布在该行上
|
|
space-around
|
弹性项目平均分布在该行上,两边留有一半的间隔空间
|
项目在容器内侧轴方位的对齐方式(align-items),用于wxss
|
属性
|
描述
|
|
stretch
|
默认值,弹性项目被拉伸以适应容器
|
|
center
|
弹性项目位于容器的中心
|
|
flex-start
|
弹性项目位于容器的开头
|
|
flex-end
|
弹性项目位于容器的结尾
|
|
baseline
|
弹性项目位于容器的基线上
|
微信小程序组件解读和分析:一、view(视图容器 )的更多相关文章
- 微信小程序组件解读和分析:六、progress进度条
progress进度条组件说明: 进度条,就是表示事情当前完成到什么地步了,可以让用户视觉上感知事情的执行.progress进度条是微信小程序的组件,和HTML5的进度条progress类似. pro ...
- 微信小程序组件解读和分析:五、text文本
text文本组件说明: text 文本就是微信小程序中显示出来的文本. text文本组件的示例代码运行效果如下: 下面是WXML代码: [XML] 纯文本查看 复制代码 ? 1 2 3 4 <v ...
- 微信小程序组件解读和分析:四、icon图标
icon图标组件说明: icon是一种图标格式,用于系统图标.软件图标等,这种图标扩展名为.icon..ico.常见的软件或windows桌面上的那些图标一般都是ICON格式的.在应用上面很多地方 ...
- 微信小程序组件解读和分析:三、swiper滑块视图
swiper滑块组件说明: 滑块视图容器,用于展示图片,可以通过用户拖拽和设置自动切换属性控制图片的切换 组件的使用示例的运行效果如下: 下面是WXML代码: [XML] 纯文本查看 复制代码 ? ...
- 微信小程序组件解读和分析:十四、slider滑动选择器
slider滑动选择器组件说明: 滑动选择器. slider滑动选择器示例代码运行效果如下: 下面是WXML代码: [XML] 纯文本查看 复制代码 ? 01 02 03 04 05 06 07 08 ...
- 微信小程序组件解读和分析:十、input输入框
input输入框组件说明: 本文介绍input 输入框的各种参数及特性. input输入框示例代码运行效果如下: 下面是WXML代码: [XML] 纯文本查看 复制代码 ? 01 02 03 04 0 ...
- 微信小程序组件解读和分析:八、checkbox复选项
checkbox复选项组件说明: checkbox是小程序表单组件中的一个组件,作用是在表单中引导用户做出选择. 要使用checkbox组件,还需要在同组中所有的checkbox标签外使用checkb ...
- 微信小程序组件解读和分析:十五、switch 开关选择器
switch 开关选择器组件说明: switch,开关选择器.只能选择或者不选.这种属于表单控件或者查询条件控件. switch 开关选择器示例代码运行效果如下: 下面是WXML代码: [XML] 纯 ...
- 微信小程序组件解读和分析:十三、radio单选项目
radio单选项目组件说明: radio:单选项目. radio-group: 单项选择器,内部由多个<radio/>组成. radio单选项目示例代码运行效果如下: 下面是WXML代码: ...
随机推荐
- 织梦文章页调用当前栏目名称和url地址的方法
其实织梦本身有这2个调用标签,可能大家没怎么注意,下面的代码就是织梦文章页调用当前栏目名称和url地址的方法: {dede:field name='typeurl' function=”GetType ...
- ajax验证用户名 当用户名框的数据改变时 执行ajax方法
ajax验证用户名 当用户名框的数据改变时 执行ajax方法 <html xmlns="http://www.w3.org/1999/xhtml" ><head ...
- DGA聚类 使用DBScan
features = sc.parallelize(data_group[idx]).map(lambda x: (x.host_ip+'^'+x.domain, 1)).reduceByKey(op ...
- uuid.js
// On creation of a UUID object, set it's initial valuefunction UUID(){ this.id = this.createUUID ...
- java内存管理--栈、堆和常量池
今天有朋友问java中String[] str = s.split(",")的内存分析,于是开始查资料并测试.首先,发现在java的内存管理中"常量池"是个很奇 ...
- [AHOI 2006] 上学路线
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1266 [算法] 首先 , 用Dijkstra求单源最短路 然后 , 建出这张图G的最 ...
- 【Educational Codeforces Round 38 (Rated for Div. 2)】 Problem A-D 题解
[比赛链接] 点击打开链接 [题解] Problem A Word Correction[字符串] 不用多说了吧,字符串的基本操作 Problem B Run for your prize[贪心] ...
- 启动和测试oracle是否安装成功
转自:https://www.cnblogs.com/justdo-it/articles/5112576.html 测试步骤1:请执行操作系统级的命令:tnsping orcl 测试步骤 2:请执行 ...
- centos7安装redis3.2.12
1.准备安装包,放在/usr/local/src/ 2.解压安装包,解压到/usr/local/ tar zxf redis-3.2.12.tar.gz -C /usr/local/ 3.cd /us ...
- [转]C# Socket编程笔记
本文转自:http://www.cnblogs.com/stg609/archive/2008/11/15/1333889.html 原文如下: 看到这个题目,是不是很眼熟?在博客园里搜下,保证会发现 ...