【问题标题】:Hide browser scroll-bars隐藏浏览器滚动条
【发布时间】:2015-08-11 01:13:00
【问题描述】:

我在 data-role="content" 中使用插件 iscroll,但我的整页中出现了一个巨大的滚动条: scrollbar

我已经尝试过在 SO 中找到的一些解决方案,例如:

  1. pilsetnieks's answer
  2. Alexander Prokofyev's answer
  3. jao's answer
  4. Mr_Green's answer

但没有任何作用。

我也检查了这个website,但也没有运气。

你能帮帮我吗?

我的HTML

<div data-role="content" data-theme="c">
            <div id="Container"></div>
            <div id="Treelist">
                <div id="scroller">
                    <ul id="Listview" ></ul>
                </div>
            </div>
        </div>

我的CSS

html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    overflow: hidden;   
}

#Treelist {
    position:relative;
    z-index:1;
    top:0; 
    bottom:0; 
    left:0;
    width:100%;
    overflow: hidden;
    /* Prevent native touch events on Windows */
    -ms-touch-action: none;
    /* Prevent the callout on tap-hold and text selection */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Prevent text resize on orientation change, useful for web-apps */
    -webkit-text-size-adjust: none;
    -moz-text-size-adjust: none;
    -ms-text-size-adjust: none;
    -o-text-size-adjust: none;
    text-size-adjust: none;
}

#scroller {
    position:relative; z-index:1;
/* Prevent elements to be highlighted on tap */
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    /* Put the scroller into the HW Compositing layer right from the start */
    -webkit-transform: translateZ(0);
    -moz-transform: translateZ(0);
    -ms-transform: translateZ(0);
    -o-transform: translateZ(0);
    transform: translateZ(0);
}


#Treelist ul {
    position:relative;
    list-style:none;
    padding:0;
    margin:0;
    width:100%;
    text-align:left;
}

#Treelist li {
    padding:0 10px;
    height:150px;
/*  line-height:40px; */
    border-bottom:1px solid #ccc;
    border-top:1px solid #fff;
    background-color:#fafafa;
    font-size:14px;
}

【问题讨论】:

  • 你是这个意思? link
  • 你是在哪个浏览器上遇到这个问题的?
  • @Mr_Green 我正在使用这个plugin
  • @Mr_Green 您的回答也无效。事实上,它让我的ul消失了
  • 那么问题似乎出在其他地方。请创建一个小小提琴来演示您的问题。如果您这样做,我们可以进一步帮助您。

标签: html css iscroll


【解决方案1】:

您可以使用它来隐藏滚动条:

#scroller::-webkit-scrollbar {
display: none;
}

#scroller {
-ms-overflow-style: none;
}

在不同的浏览器上看看,我确定它在 Safari、IE 和 Chrome 中都可以工作

【讨论】:

  • 滚动条仍然存在 :(
【解决方案2】:

这应该适用于基于 Webkit 的浏览器(Chrome/Safari)以及 IE 10+。

div::-webkit-scrollbar { width: 0 !important; display: none; }
div { -ms-overflow-style: none; }

不幸的是,没有很好的跨浏览器解决方案来编辑​​滚动条。滚动条是由浏览器创建的,因此我们可以对它们做的数量受到浏览器允许的限制。我知道最好不要管它们,大多数人甚至都不会注意到它们。

【讨论】:

  • 滚动条仍然存在
猜你喜欢
  • 2018-01-12
  • 1970-01-01
  • 2018-10-31
  • 2021-08-25
  • 2010-09-06
  • 2021-10-17
  • 2018-08-31
  • 1970-01-01
相关资源
最近更新 更多