国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

小程序scroll-view安卓機隱藏橫向滾動條的實現詳解

2019-11-19 11:32:42
字體:
來源:轉載
供稿:網友

一、實踐踩坑

項目使用mpvue開發

1.使用flex布局

// html大概長這樣<div class="worth-wraper"> <scroll-view scroll-x="true" scroll-left="0"> <div class="worth-list"> <div class="worth-item-img"> <img src="/static/images/index/brand1.png" alt=""> </div> <div class="worth-item-img"> <img src="/static/images/index/brand2.png" alt=""> </div> <div class="worth-item-img"> <img src="/static/images/index/brand3.png" alt=""> </div> <div class="worth-item-img"> <img src="/static/images/index/brand4.png" alt=""> </div> </div> </scroll-view></div>
// css相應就大概長這樣.worth-wraper{margin-top: 60rpx;height: 560rpx;box-sizing: border-box;display: flex;width: 750rpx;overflow: hidden;font-size: 28rpx;color: #7a7269;line-height: 42rpx;.worth-list{ display: flex; margin-left: 30rpx; .worth-item-img{   flex: 1;   margin-right: 20rpx;   width: 290rpx;   height: 560rpx; } img{  width: 290rpx;  height: 560rpx; } .worth-item{  padding: 0 35rpx 0 40rpx;  flex: 1;  box-sizing: border-box;  background: url("../../../static/images/index/worth-bg1.png") no-repeat;  background-size: 100% 100%;  width: 290rpx;  height: 560rpx;  margin-right: 20rpx; }}}

ios沒有問題,樣式正常,然后到了安卓機上,卻出現了橫向滾動條.......然后各種找如何去除橫向滾動條的方法....

二、隱藏滾動條

在網上搜了很多,都是說加上這段代碼就可以:

/隱藏滾動條/::-webkit-scrollbar{width: 0;height: 0;color: transparent;}

或者有的人說這樣子:

/隱藏滾動條/::-webkit-scrollbar{display: none;}

然而兩種方法我都試過,然而在安卓機上并沒什么鳥用。

后來看到有人這么說:

1.scroll-view 中的需要滑動的元素不可以用 float 浮動;

2.scroll-view 中的包裹需要滑動的元素的大盒子用 display:flex; 是沒有作用的;

3.scroll-view 中的需要滑動的元素要用 dislay:inline-block; 進行元素的橫向編排;

4.包裹 scroll-view 的大盒子有明確的寬和加上樣式--> overflow:hidden;white-space:nowrap;

好像能行得通....不用flex,不用float

然后改寫css代碼

.worth-wraper{ margin-top: 60rpx; width: 750rpx; height: 560rpx; overflow: hidden;  scroll-view{  width: 100%;  white-space: nowrap; } .worth-list{  display: inline-block;  margin-left: 30rpx;  padding-bottom: 60rpx; //加個padding值,這樣高度大于scroll-view外面包裹的元素  .worth-item-img{   margin-right: 20rpx;   width: 290rpx;   height: 560rpx;   display: inline-block;  } }}

到這里,scroll-view安卓機上橫向滾動條消失了,大概長這樣:

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 启东市| 亳州市| 同德县| 松溪县| 高雄市| 南岸区| 铜山县| 化德县| 车致| 南召县| 岚皋县| 航空| 盐边县| 乾安县| 台东市| 黄石市| 日照市| 武隆县| 涿鹿县| 龙川县| 五大连池市| 壶关县| 马尔康县| 丰城市| 鲁甸县| 右玉县| 合肥市| 吉水县| 安丘市| 耒阳市| 获嘉县| 上饶县| 沈丘县| 婺源县| 新竹县| 客服| 苍南县| 万源市| 太和县| 徐水县| 青冈县|