今天寫第一篇關于微信小程序的學習,view的創建和使用。
微信小程序開發需要學習基本的標簽,這對我來說是一個挑戰,不過加油啊。
1.創建一個View
在wxml中 <view class="section"></view>定義(容我這么說,對于iOS熟悉的人比較了解吧,不管對不對吧)。
在wxss中實現如下,
.section { flex: 1; background-color: #ffff00; font-size: 16px;
padding: 10px;
margin: 10px;}
其中,background-color背景顏色,font-size是文字大小。padding文字與父試圖之間的距離,margin整個空間與父視圖中間距離。
2.view的樣式
<view style="display : flex;flex-direction:row"> <view class="flex-item bc_green"></view> <view class="flex-item bc_red"></view> <view class="flex-item bc_blue"></view>
</view>
class是一個控件,style是樣式,
"display : flex;flex-direction:row表示為橫向布局。display : flex;flex-direction:column豎向布局。
display : flex;flex-direction:row;justify-content:flex-start 橫向布局左側開始
display : flex;flex-direction:row;justify-content:flex-end 橫向布局右側開始
display : flex;flex-direction:row;justify-content:center 橫向布局居中
display : flex;flex-direction:row;justify-content:space-between 橫向布局子控件分開排列,左右間距為0
display : flex;flex-direction:row;justify-content:space-around 橫向布局子控件邊上有環繞
display : flex;height:200px;flex-direction:row;justify-content:space-around;align-items:flex-start 橫向布局子控件邊上有環繞+從上面開始
display : flex;height:200px;flex-direction:row;justify-content:space-around;align-items:flex-end 橫向布局子控件邊上有環繞+從下面開始
display : flex;height:200px;flex-direction:row;justify-content:space-around;align-items:center 橫向布局子控件邊上有環繞+從中間開始
flex-item表示一個控件,在wuss中可定義如寬高,bc_green bc_red bc_blue 具體的顏色
新聞熱點
疑難解答