微信小程序 滚动视图弹性布局

.wxml

<scroll-view class="scroll" scroll-x="true" scroll-left="string" enable-flex="true" bindscrolltolower="history">
  <block wx:for="{{history}}" wx:key="history">
     <view class="history-content">
       <image src="{{item.img}}"></image>
       <view>{{item.name}}</view>
     </view>
  </block>
</scroll-view>

.wxss

.scroll{
  height: 400rpx;
  margin-top: 20rpx;
  display: flex;
  flex-direction: row;
  text-align: center;
}
.history-content{
  width: 400rpx;
  height: 360rpx;
  display: flex;
  flex-direction: column;
  margin-right: 20rpx;
  font-size: 30rpx;
}
.history-content image{
  width: 220rpx;
  height: 310rpx;
}

效果图

 纵向滚动

.wxml

<scroll-view class="recommend-scroll" scroll-y="true" scroll-top="string" enable-flex="true" bindscrolltolower="recommend">
   <block wx:for="{{recommend}}" wx:key="recommend">
      <view class="recommend-content">
        <image src="{{item.img}}"></image>
        <view class="recommend-desc">
         <view class="recommend-desc-name">{{item.name}}</view>
         <view class="recommend-desc-author">{{item.author}}</view>
         <view class="recommend-desc-score">☆☆☆☆☆ ({{item.score}})</view>
         <view class="recommend-desc-content">{{item.desc}}</view>
        </view>
      </view>
  </block>
</scroll-view>

.wxss

.recommend-scroll{
  display: flex;
  flex-direction: column;
  height: 600rpx;
  margin-top: 20rpx;
}

.recommend-content{
  display: flex;
  flex-direction: row;
  width: 700rpx;
  margin-top: 20rpx;
}

.recommend-content image{
  width:180rpx;
  height: 260rpx;
  border-radius: 20rpx;
}
.recommend-desc{
  width: 500rpx;
  margin-left: 20rpx;
  display: flex;
  flex-direction: column;
}
.recommend-desc-name{
  font-size: 40rpx;
  font-weight: 700;
}
.recommend-desc-author{
  font-size: 30rpx;
  margin-top: 10rpx;  
  color: gray;
}
.recommend-desc-score{
  font-size: 30rpx;
}
.recommend-desc-content{
  font-size: 28rpx;
  margin-top: 10rpx;
}

效果图

注意:其中的数据是个人请求的测试的数据和绑定,使用时将内容改动,这里只是样式 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值