微信小程式 View元件詳細介紹

高洛峰
發布: 2017-02-23 15:10:57
原創
2336 人瀏覽過

這篇文章主要介紹了微信小程式View元件詳細介紹的相關資料,需要的朋友可以參考下

微信小程序 View组件详细介绍

#剛看到這個效果的時候還真是和ReactNative的效果一致,屬性也基本的一樣.

view 這個元件就是一個視圖元件使用起來非常簡單。

主要屬性:

flex-direction: 主要兩個特性」row」橫向排列”column」縱向排列

justify- content 主軸的對齊方式(如果flex-direction為row則主軸就是水平方向)

#可選屬性('flex-start', 'flex-end', 'center', 'space- between', 'space-around')

align-items 側軸對齊方式如果flex-direction為row則側軸就是垂直方向)

可選屬性('flex-start', 'flex-end', 'center')

wxml


#
<view class="page">
 <view class="page__hd">
  <text class="page__title">view</text>
  <text class="page__desc">弹性框模型分为弹性容器以及弹性项目。当组件的display为flex或inline-flex时,该组件则为弹性容器,弹性容器的子组件为弹性项目。</text>
 </view>
 <view class="page__bd">
  <view class="section">
   <view class="section__title">flex-direction: row</view>
   <view class="flex-wrp" style="flex-direction:row;">
    <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>
  </view>
  <view class="section">
   <view class="section__title">flex-direction: column</view>
   <view class="flex-wrp" style="height: 300px;flex-direction: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>
  </view>
  <view class="section">
   <view class="section__title">justify-content: flex-start</view>
   <view class="flex-wrp" style="flex-direction:row;justify-content: 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>
  </view>
  <view class="section">
   <view class="section__title">justify-content: flex-end</view>
   <view class="flex-wrp" style="flex-direction:row;justify-content: 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>
  </view>
  <view class="section">
   <view class="section__title">justify-content: center</view>
   <view class="flex-wrp" style="flex-direction:row;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>
  </view>
  <view class="section">
   <view class="section__title">justify-content: space-between</view>
   <view class="flex-wrp" style="flex-direction:row;justify-content: 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>
  </view>
  <view class="section">
   <view class="section__title">justify-content: space-around</view>
   <view class="flex-wrp" style="flex-direction:row;justify-content: 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>
  </view>
  <view class="section">
   <view class="section__title">align-items: flex-end</view>
   <view class="flex-wrp" style="height: 200px;flex-direction:row;justify-content: center;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>
  </view>
  <view class="section">
   <view class="section__title">align-items: center</view>
   <view class="flex-wrp" style="height: 200px;flex-direction:row;justify-content: center;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>
  </view>

  <view class="section">
   <view class="section__title">align-items: center</view>
   <view class="flex-wrp" style="height: 200px;flex-direction:row;justify-content: center;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>
  </view>

 </view>
</view>
登入後複製



################################# #####wxss###############
.flex-wrp{
 height: 100px;
 display:flex;
 background-color: #FFFFFF;
}
.flex-item{
 width: 100px;
 height: 100px;
}
登入後複製
###更多微信小程式View元件詳細介紹相關文章請關注PHP中文網! ###
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板