国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

微信小程序 簡單DEMO布局,邏輯,樣式的練習

2019-11-19 18:45:14
字體:
來源:轉載
供稿:網友

微信小程序 布局實例:

下面將會按照以下的順序介紹:

布局的實現
邏輯的實現
樣式的實現

1.布局的實現

最大的布局是view, view布局中包含了:一張圖片,文字描述,信息欄和分界線

<!--最外層--><view class="home-view1">  <!--圖片層-->  <view class="home-view2">    <image class="home-image1" src="http://qty83k.creatby.com/materials/origin/640e31829b8776967dedc670b5427d0f_origin.jpg"></image>  </view>  <!--描述層-->  <text class="home-text1">小巧可愛的案頭雅物小巧可愛的案頭雅物小巧可愛的案頭雅物小巧可愛的案頭雅物小巧可愛的案頭雅物</text>  <!--信息層-->  <view class="home-view3">     <view class="home-view4" >      <image class="home-image-heart" src="http://qty83k.creatby.com/materials/origin/c5656ef00d38d89eae437c5a9102f8fa_origin.png"></image>      <text class="home-text-heart bgColor" > 22</text>    </view>    <text class="home-text-time" >2016.10.29</text>  </view>  <!--分界線line-->  <view class="home-view-line"></view>  <!--圖片層(下面的代碼直接復制了上面的所有布局代碼)-->  <view class="home-view2">    <image class="home-image1" src="http://qty83k.creatby.com/materials/origin/640e31829b8776967dedc670b5427d0f_origin.jpg"></image>  </view>  <!--描述層-->  <text class="home-text1">小巧可愛的案頭雅物小巧可愛的案頭雅物小巧可愛的案頭雅物小巧可愛的案頭雅物小巧可愛的案頭雅物</text>  <!--信息層-->  <view class="home-view3">     <view class="home-view4" >      <image class="home-image-heart" src="http://qty83k.creatby.com/materials/origin/c5656ef00d38d89eae437c5a9102f8fa_origin.png"></image>      <text class="home-text-heart bgColor" > 22</text>    </view>    <text class="home-text-time" >2016.10.29</text>  </view>  <!--分界線line-->  <view class="home-view-line"></view></view>

2.邏輯的實現

只是注冊了Page界面

Page({  data:{  }})

3.樣式的實現

.home-view1樣式:display規定最大View布局為彈性布局,justify-content規定內容居中,豎直排列, …

.home-view3樣式:display規定了信息欄布局為彈性布局,justify-content規定內容水平平均分配

.home-view4樣式:display規定了收藏圖片和收藏數的父布局為彈性布局,align-items規定內容在豎直方向居中

.home-image1樣式:規定圖片的高度

.home-image-heart樣式:規定收藏圖片的大小

.home-text1樣式:規定描述文字的樣式,text-align規定文字居中,line-height規定兩行文字之間的高度

.home-text-heart樣式:規定收藏數的樣式,border-radius規定邊界圓角

.home-view-line樣式:是一條分界線

.bgColor樣式:規定收藏數的背景

.home-view1{  display: flex;  justify-content: center;  flex-direction: column;  height: 100%;  width: 100%;  margin: 6px;}.home-view3{  display: flex;  justify-content: space-between;}.home-view4{  display: flex;  align-items: center;}.home-image1{  height: 200px;}.home-image-heart{  width: 30px;  height: 30px;}.home-text1{  text-align: left;  line-height: 25px;  margin-top: 6px;  margin-right: 6px;  color: gray;}.home-text-heart{  width: 22px;  height: 22px;  margin-left: 10px;  border-radius: 20%;  pad: 5px;  text-align: center;}.home-text-time{  text-align: center;  margin-right: 20px;  padding-top: 5px;  color: gray;}.home-view-line{ width: 100%; height: 6px; margin-top: 5px; background-color: gainsboro;}.bgColor{  background-color: lightblue;  opacity: 0.6;}

4.效果圖

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宿州市| 始兴县| 双城市| 和田市| 营口市| 黎川县| 建平县| 黄龙县| 论坛| 怀化市| 册亨县| 伊吾县| 基隆市| 错那县| 武穴市| 台东市| 固阳县| 凤翔县| 白城市| 中西区| 镇平县| 乌拉特后旗| 龙陵县| 乐都县| 镇沅| 龙川县| 大新县| 重庆市| 保定市| 平江县| 类乌齐县| 白玉县| 伊通| 光山县| 卢龙县| 天津市| 临城县| 馆陶县| 石河子市| 原平市| 额尔古纳市|