微信小程序布局实例

//index.js
Page({
  data:{
    imgUrls: [
      'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
    ],
    contentItems:['','','',''],
    listItems:['','','','','','','']
  }
})
index.wxml

<view class="container">
 
  <view class="selection">
    <swiper indicator-dots="true"
      autoplay="true" interval="3000" duration="1000">
      <block wx:for="{{imgUrls}}">
        <swiper-item>
          <image src="{{item}}" class="slide-image" width="355" height="150"/>
        </swiper-item>
      </block>
    </swiper>
  </view>


  <view class="selection">
      <view class="header">
           <text>精品推荐</text>
            <text class="text-all">全部精品</text>
      </view>


      <view class="content">
          <view class="content-item" wx:for="{{contentItems}}">
             <image src="../../images/img1.png" />
             <view class="content-item-text">
              <text>这里是标题</text>
             </view>
          </view>

         

      </view>

  </view>



  <view class="selection">
      <view class="header">
           <text>热门评测</text>
            <text class="text-all">全部评测</text>
      </view>

      <view class="list-item" wx:for="{{listItems}}">

            <view class="list-item-images">
                 <image src="../../images/img2.png" class="list-item-images-img" />
                 <image src="../../images/avatar.png" class="avatar" />
            </view>

            <view class="list-item-text">
                <view class="list-item-text-title">
                  <text>标题标题标题</text>
                </view>

                <view class="list-item-text-content">
                  <text>这里是内容,这里是内容,这里是内容,这里是内容,这里是内容,这里是内容,这里是内容,这里是内容,</text>
                </view>

            </view>

      </view>


  </view>


</view>
/* index.wxss */
.selection{
  border-bottom: 5px solid #ddd;

}


.header{
  border-left-width: 2px;
  border-left-style: solid;
  border-left-color: limegreen;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60rpx;
  padding-left: 10rpx;
  padding-right: 10rpx;
  margin-top: 10rpx;
  margin-bottom: 10rpx;
}

.text-all{
  color: green;
  font-size: 10px;
}

.content{
   display: flex;
   flex-direction: row;
   flex-wrap: wrap;
   justify-content: center;
}

.content-item{
  height: 250rpx;
  width: 45%;
  background-color: goldenrod;
  margin: 5px;
  position: relative;
}

.content-item image{
  width: 100%;
  height: 100%;
}

.content-item-text{
  position: absolute;
  bottom: 0px;
  color: white;
  font-size: 10px;
  background: -webkit-linear-gradient(bottom,rgba(0, 0, 0, 0.8),rgba(0, 0, 0, 0));
  height: 125rpx;
  width: 98%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-left: 1%;
  padding-right: 1%;
  padding-bottom: 1%;
}

.list-item{
  height: 500rpx;
  width: 100%;
}
.list-item-images{
   height: 300rpx;
   width: 100%;
   position: relative;
}

.list-item-images-img{
   height: 100%;
   width: 100%;
}


.avatar{
  width: 100rpx;
  height: 100rpx;
  border-radius: 50%;
  position: absolute;
  bottom: -50rpx;
  right: 50rpx;
}


.list-item-text{
  height: 200rpx;
  width: 96%;
  margin-top: 20rpx;
  padding-left: 2%;
  padding-right: 2%; 
}

.list-item-text-content{
  font-size: 10px;
  color: #999;
  margin-top: 20rpx;

}

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

smartsmile2012

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值