微信小程序 簡單DEMO布局,邏輯,樣式的練習(xí)
微信小程序 布局實(shí)例:
下面將會按照以下的順序介紹:
布局的實(shí)現(xiàn)
邏輯的實(shí)現(xiàn)
樣式的實(shí)現(xiàn)
1.布局的實(shí)現(xiàn)
最大的布局是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>
<!--圖片層(下面的代碼直接復(fù)制了上面的所有布局代碼)-->
<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.邏輯的實(shí)現(xiàn)
只是注冊了Page界面
Page({
data:{
}
})
3.樣式的實(shí)現(xiàn)
.home-view1樣式:display規(guī)定最大View布局為彈性布局,justify-content規(guī)定內(nèi)容居中,豎直排列, …
.home-view3樣式:display規(guī)定了信息欄布局為彈性布局,justify-content規(guī)定內(nèi)容水平平均分配
.home-view4樣式:display規(guī)定了收藏圖片和收藏?cái)?shù)的父布局為彈性布局,align-items規(guī)定內(nèi)容在豎直方向居中
.home-image1樣式:規(guī)定圖片的高度
.home-image-heart樣式:規(guī)定收藏圖片的大小
.home-text1樣式:規(guī)定描述文字的樣式,text-align規(guī)定文字居中,line-height規(guī)定兩行文字之間的高度
.home-text-heart樣式:規(guī)定收藏?cái)?shù)的樣式,border-radius規(guī)定邊界圓角
.home-view-line樣式:是一條分界線
.bgColor樣式:規(guī)定收藏?cái)?shù)的背景
.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.效果圖

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
Server-sent?events實(shí)時(shí)獲取服務(wù)端數(shù)據(jù)技術(shù)詳解
這篇文章主要為大家介紹了Server-sent?events實(shí)時(shí)獲取服務(wù)端數(shù)據(jù)技術(shù)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-02-02
javascript 操作cookies詳解及實(shí)例
這篇文章主要介紹了javascript 操作cookies詳解及實(shí)例的相關(guān)資料,需要的朋友可以參考下2017-02-02
JavaScript高級程序設(shè)計(jì)之基本引用類型
這篇文章主要介紹了JavaScript高級程序設(shè)計(jì)之基本引用類型,引用值(對象)都是某個(gè)特定的引用類型的實(shí)例對象,例如 Date類型、Function類型,RegExp 正則表達(dá)式類型等等。JavaScript內(nèi)置了一些常用的引用類型給開發(fā)者使用。下面來看看文章詳細(xì)內(nèi)容2021-11-11
實(shí)踐示例理解js強(qiáng)緩存協(xié)商緩存
這篇文章主要為大家以實(shí)踐示例理解js強(qiáng)緩存協(xié)商緩存,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07

