|
3 | 3 | <page-head title="view"></page-head> |
4 | 4 | <view class="uni-padding-wrap uni-common-mt"> |
5 | 5 | <view class="uni-hello-text"> |
6 | | - Flex是Flexible Box的缩写,意为“弹性布局”,用来为盒状模型提供最大的灵活性。当设置display: flex后,继续给view等容器组件设置flex-direction: row或column,就可以在该容器内按行或列排布子组件。uni-app默认全局使用flex布局(在App.vue里预设了)。因为flex布局有利于跨更多平台,尤其是采用原生渲染的平台。 |
| 6 | + Flex是Flexible Box的缩写,意为“弹性布局”,用来为盒状模型提供最大的灵活性。当设置display: flex后,继续给view等容器组件设置flex-direction: |
| 7 | + row或column,就可以在该容器内按行或列排布子组件。uni-app默认全局使用flex布局(在App.vue里预设了)。因为flex布局有利于跨更多平台,尤其是采用原生渲染的平台。 |
7 | 8 | </view> |
8 | | - |
| 9 | + |
9 | 10 | <view class="uni-title uni-common-mt"> |
10 | 11 | flex-direction: row |
11 | 12 | <text>\n横向布局</text> |
|
15 | 16 | <view class="flex-item uni-bg-green">B</view> |
16 | 17 | <view class="flex-item uni-bg-blue">C</view> |
17 | 18 | </view> |
18 | | - |
| 19 | + |
19 | 20 | <view class="uni-title uni-common-mt"> |
20 | 21 | flex-direction: column |
21 | 22 | <text>\n纵向布局</text> |
|
25 | 26 | <view class="flex-item flex-item-V uni-bg-green">B</view> |
26 | 27 | <view class="flex-item flex-item-V uni-bg-blue">C</view> |
27 | 28 | </view> |
28 | | - |
| 29 | + |
29 | 30 | <view class="uni-title uni-common-mt"> |
30 | 31 | 更多布局示例 |
31 | 32 | <text>\nflex布局演示</text> |
|
37 | 38 | <view class="text">横向布局-自动宽度</view> |
38 | 39 | <view class="text">横向布局-自动宽度</view> |
39 | 40 | </view> |
40 | | - <view class="uni-flex uni-row" style="justify-content: center;"> |
| 41 | + <view class="uni-flex uni-row" style="-webkit-justify-content: center;justify-content: center;"> |
41 | 42 | <view class="text">横向布局-居中</view> |
42 | 43 | <view class="text">横向布局-居中</view> |
43 | 44 | </view> |
44 | | - <view class="uni-flex uni-row" style="justify-content: flex-end;"> |
| 45 | + <view class="uni-flex uni-row" style="-webkit-justify-content: flex-end;justify-content: flex-end;"> |
45 | 46 | <view class="text">横向布局-居右</view> |
46 | 47 | <view class="text">横向布局-居右</view> |
47 | 48 | </view> |
48 | 49 | <view class="uni-flex uni-row"> |
49 | | - <view class="text" style="flex: 1;">横向布局-平均分布</view> |
50 | | - <view class="text" style="flex: 1;">横向布局-平均分布</view> |
| 50 | + <view class="text" style="-webkit-flex: 1;flex: 1;">横向布局-平均分布</view> |
| 51 | + <view class="text" style="-webkit-flex: 1;flex: 1;">横向布局-平均分布</view> |
51 | 52 | </view> |
52 | | - <view class="uni-flex uni-row" style="justify-content: space-between;"> |
| 53 | + <view class="uni-flex uni-row" style="-webkit-justify-content: space-between;justify-content: space-between;"> |
53 | 54 | <view class="text">横向布局-两端对齐</view> |
54 | 55 | <view class="text">横向布局-两端对齐</view> |
55 | 56 | </view> |
56 | 57 | <view class="uni-flex uni-row"> |
57 | 58 | <view class="text" style="width: 200upx;">固定宽度</view> |
58 | | - <view class="text" style="flex: 1;">自动占满余量</view> |
| 59 | + <view class="text" style="-webkit-flex: 1;flex: 1;">自动占满余量</view> |
59 | 60 | </view> |
60 | 61 | <view class="uni-flex uni-row"> |
61 | 62 | <view class="text" style="width: 200upx;">固定宽度</view> |
62 | | - <view class="text" style="flex: 1;">自动占满</view> |
| 63 | + <view class="text" style="-webkit-flex: 1;flex: 1;">自动占满</view> |
63 | 64 | <view class="text" style="width: 200upx;">固定宽度</view> |
64 | 65 | </view> |
65 | 66 | <view class="uni-flex uni-row" style="-webkit-flex-wrap: wrap;flex-wrap: wrap;"> |
|
68 | 69 | <view class="text" style="width: 280upx;">一行显示不全,wrap折行</view> |
69 | 70 | </view> |
70 | 71 | <view class="uni-flex uni-row"> |
71 | | - <view class="text" style="flex: 1;height: 200upx;display: flex; justify-content: center;align-items: flex-start;"> |
| 72 | + <view class="text uni-flex" style="-webkit-flex: 1;flex: 1;height: 200upx;-webkit-justify-content: center;justify-content: center;-webkit-align-items: flex-start;align-items: flex-start;"> |
72 | 73 | <text>垂直居顶</text> |
73 | 74 | </view> |
74 | | - <view class="text" style="flex: 1;height: 200upx;display: flex; justify-content: center;align-items: center;"> |
| 75 | + <view class="text uni-flex" style="-webkit-flex: 1;flex: 1;height: 200upx;-webkit-justify-content: center;justify-content: center;-webkit-align-items: center;align-items: center;"> |
75 | 76 | <text>垂直居中</text> |
76 | 77 | </view> |
77 | | - <view class="text" style="flex: 1;height: 200upx;display: flex; justify-content: center;align-items: flex-end;"> |
| 78 | + <view class="text uni-flex" style="-webkit-flex: 1;flex: 1;height: 200upx;-webkit-justify-content: center;justify-content: center;-webkit-align-items: flex-end;align-items: flex-end;"> |
78 | 79 | <text>垂直居底</text> |
79 | 80 | </view> |
80 | 81 | </view> |
81 | 82 | </view> |
82 | | - |
| 83 | + |
83 | 84 | <view class="uni-title uni-common-mt"> |
84 | 85 | 组合示例 |
85 | 86 | <text>\nflex布局演示</text> |
86 | 87 | </view> |
87 | 88 | <view class="uni-flex uni-row"> |
88 | | - <view class="text" style="width: 200upx;height: 220upx;display: flex; justify-content: center;align-items: center;"> |
| 89 | + <view class="text" style="width: 200upx;height: 220upx;display: -webkit-flex;display: flex; -webkit-justify-content: center;justify-content: center;-webkit-align-items: center;align-items: center;"> |
89 | 90 | <image src="../../../static/plus.png" style="width: 150upx;height: 150upx;"></image> |
90 | 91 | </view> |
91 | | - <view class="uni-flex uni-column" style="flex: 1;justify-content: space-between;"> |
| 92 | + <view class="uni-flex uni-column" style="-webkit-flex: 1;flex: 1;-webkit-justify-content: space-between;justify-content: space-between;"> |
92 | 93 | <view class="text" style="height: 120upx;text-align: left;padding-left: 20upx;padding-top: 10upx;"> |
93 | 94 | 文字居左,留出左间距 |
94 | 95 | </view> |
95 | 96 | <view class="uni-flex uni-row"> |
96 | | - <view class="text" style="flex: 1;">剩余数量</view> |
97 | | - <view class="text" style="flex: 1;">立即购买</view> |
| 97 | + <view class="text" style="-webkit-flex: 1;flex: 1;">剩余数量</view> |
| 98 | + <view class="text" style="-webkit-flex: 1;flex: 1;">立即购买</view> |
98 | 99 | </view> |
99 | 100 | </view> |
100 | 101 | </view> |
|
104 | 105 | <script> |
105 | 106 | export default { |
106 | 107 | data() { |
107 | | - return { |
108 | | - } |
| 108 | + return {} |
109 | 109 | } |
110 | 110 | } |
111 | 111 | </script> |
|
124 | 124 | text-align: center; |
125 | 125 | line-height: 150upx; |
126 | 126 | } |
127 | | - .text{ |
128 | | - margin:15upx 10upx; |
| 127 | +
|
| 128 | + .text { |
| 129 | + margin: 15upx 10upx; |
129 | 130 | padding: 0 20upx; |
130 | 131 | background-color: #ebebeb; |
131 | 132 | height: 70upx; |
|
134 | 135 | color: #777; |
135 | 136 | font-size: 26upx; |
136 | 137 | } |
137 | | - .desc{ |
| 138 | +
|
| 139 | + .desc { |
138 | 140 | /* text-indent: 40upx; */ |
139 | 141 | } |
140 | | -</style> |
| 142 | +</style> |
0 commit comments