在移动浏览器中显示滚动条 [英] Make scrollbar visible in mobile browsers
问题描述
当我有一个可滚动内容的网页。使用css属性overflow:auto或overflow:visible,滚动条在桌面浏览器上可见,但是当我在移动浏览器上打开页面时,滚动条仅在我尝试滚动时显示。
有没有办法使滚动条在移动设备上始终可见?我尝试了一些JQuery库,但没有一个工作。
when I have a web page with a scrollable content. With css property "overflow:auto" or "overflow:visible" the scrollbar is visible on desktop browsers, but when I open the page on mobile browsers the scrollbar appears only when I try to scroll. Is there a way to make the scrollbar always visible on mobile devices? I have tried some JQuery libraries but none of them have worked.
html代码很简单,我有一个可滚动的div与IFrame里面:
The html code is trivial, I have a scrollable div with an IFrame inside:
<div id="wrapper">
<iframe id="frameContent" src="mysite" scrollable="yes"></iframe>
</div>
css:
#wrapper{
overflow: scroll;
-webkit-overflow-scrolling: touch;
width: 500px;
height: 200px;
}
#frameContent{
width: 100%;
height: 100%;
}
推荐答案
Try adding the below to your CSS, note that this is webkit specific:
::-webkit-scrollbar {
-webkit-appearance: none;
}
::-webkit-scrollbar:vertical {
width: 12px;
}
::-webkit-scrollbar:horizontal {
height: 12px;
}
::-webkit-scrollbar-thumb {
background-color: rgba(0, 0, 0, .5);
border-radius: 10px;
border: 2px solid #ffffff;
}
::-webkit-scrollbar-track {
border-radius: 10px;
background-color: #ffffff;
}
这篇关于在移动浏览器中显示滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!