微信小程序-仿果库列表

这个篇文章带大家一起练练微信小程序布局。
下面将会按照以下的顺序介绍:
布局的实现
逻辑的实现
样式的实现

1.布局的实现

<!--最外层-->

<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.效果图


来源:http://bbs.520it.com/forum.php?mod=viewthread&tid=2871

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 13,806评论 1 92
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,432评论 25 708
  • 移动开发基本知识点 一.使用rem作为单位 html { font-size: 100px; } @media(m...
    横冲直撞666阅读 3,518评论 0 6
  • 昨天学习了双赢思维,那么双赢思维的前提就是理解别人,而理解别人的前提,是倾听。但很多时候我们并不是真的懂倾听,因为...
    LoveYoga喵喵阅读 1,912评论 1 2
  • 人生,最忌讳没有目标,盲从,不知道做什么。 那么,目前就给自己定下目标吧: 1 工作地点:苏州。 2 职业规划: ...
    兔子乖乖阅读 197评论 0 1