自己开发的程序scroll-y始终无效果,上网找了个例程新建项目写进去,还是无效果,scroll-x可用。
HTML代码如下:
< view class = "title" >垂直滚动</ view > < scroll-view class = "scroll_view_vertical" scroll-y > < view class = "item" >line1</ view > < view class = "item" >line2</ view > < view class = "item" >line3</ view > < view class = "item" >line4</ view > < view class = "item" >line5</ view > < view class = "item" >line6</ view > < view class = "item" >line7</ view > < view class = "item" >line8</ view > < view class = "item" >line9</ view > < view class = "item" >line10</ view > < view class = "item" >line11</ view > < view class = "item" >line12</ view > </ scroll-view > < view class = "title" >水平滚动</ view > < scroll-view class = "scroll_view_horizotal" scroll-x> < view >1111111111111111111111111111111111111111111111111111111111</ view > </ scroll-view > < view class = "copyright" > < view class = "copyright_item" >CopyRight:All Right Reserved</ view > < view class = "copyright_item" >作者:FutureJet</ view > < view class = "copyright_item" >公众号(仅供学习交流):TITF</ view > < view class = "copyright_item" >< image class = "img" src = "../../utils/image/erweima.jpg" /></ view >
|
CSS代码如下:
.title{ height : 30px ; text-align : center ; } .scroll_view_vertical{ height : 50% ; margin-bottom : 20px ; background-color : ghostwhite; } .scroll_view_horizotal{ height : 50px ; background-color : whitesmoke; } .item{ height : 50px ; } .copyright{ color : white ; padding : 5px ; margin-right : 3px ; margin-left : 3px ; text-align : center ; background-color : darkblue; } .copyright_item{ margin-top : 5px ; } .img{ width : 200px ; height : 200px ; margin-bottom : 5px ; } |
贴张图吧,研究了一晚上了,我尽力了,求指点。
网友回复:
把 height:50% 改成 height:50vh 试试?
这个比较坑,我在wxml里面设置height有用,但是wcss里面没用
50 vh 有效,搞定了,感谢!
高度不要定为50%,scroll-view应该有个固定的高度,你的问题就出在这里
把scroll-view的 height:设为固定***rpx试一下
scroll-y =‘true'
scroll-y="true"