微信小程序5--svroll-view

scroll-view就是用来设置滚动视图存在的。
这里写图片描述

1.scroll-x和scroll-y(控制view的滚动方向)
这里写图片描述

<1>index.wxml

<!--index.wxml-->
<view >
<view class="title"> scroll-view</view>

<scroll-view class="scroll-y"  scroll-y="true">
<view class="y-view red"> a1</view>
<view class="y-view green"> a2</view>
<view class="y-view blue"> a3</view>
</scroll-view>

<scroll-view class="scroll-x"  scroll-x="true" >
<view class="x-view red"> a1</view>
<view class="x-view green"> a2</view>
<view class="x-view blue"> a3</view>
</scroll-view>

</view>

<2>index.wxss(在这里有两点得注意,看代码)

/**index.wxss**/
.title{
height: 60px;
font-size: 40px;
background-color: #fff000;
  color: #09BB07;
}
.scroll-y{
  height: 200px;
  background-color: #fff000;
  margin-top: 15px;

}
.scroll-x{
   white-space: nowrap;//这里为了让那三个视图按横向排序
  height: 200px;
  background-color: #fff000;
  margin-top: 15px;
}
.x-view{
  display: inline-block;//这里为了让那三个颜色的view块状化
 height: 200px;
 width: 100%;
}
.y-view{
 height: 200px;
 width: 100%;
}
.green{
    background-color: #09BB07;
     width: 100%;
    height: 200xp;
}
.red{
     background-color: #F76260;
    width: 100%;
    height: 200xp;
}
.blue{
     background-color: #10AEFF;
     width: 100%;
    height: 200xp;
}
.yellow{
     background-color: #FFBE00;
}
.gray{
     background-color: #C9C9C9;
}

2.scroll-into-view=”id的名字”–(设置谁的id,谁就第一个显示)

第一个本来是红色,但我们把id设置为绿色的就第一个显示绿色

<scroll-view class="scroll-y"  scroll-y="true"scroll-into-view="green">
<view class="y-view red"> a1</view>
<view id="green"class="y-view green"> a2</view>
<view class="y-view blue"> a3</view>
</scroll-view>

3.scroll-left=”数值”设置多少,刚进去的时候滚动条就离左边多远,scroll-top也一样

<scroll-view class="scroll-x"  scroll-x="true" scroll-left="200" >
<view class="x-view red"> a1</view>
<view class="x-view green"> a2</view>
<view class="x-view blue"> a3</view>
</scroll-view>

4.其他属性目前还在开发中

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值