Hiding WebKit scrollbar when overflow-scrolling: touch is enabled - html

As we all know, you can hide a scrollbar in Safari and Chromium with the following CSS snippet:
::-webkit-scrollbar {
display: none;
}
However, this doesn't seem to work when -webkit-overflow-scrolling is set to touch, specifically on iOS. Chromium properly hides the scrollbar.
Is this a WebKit bug, or is there a way to hide a scrollbar AND enable fluid (touch) scrolling? It seems to be possible (perhaps with js?), on the mobile version of Google. Looking through the page source and googling my answer didn't seem to help though.

It seems that currently (as of January 2017) the only way to get around this is by wrapping the scrollable element inside of a parent div and manually hiding the scrollbar from view.
This can be achieved by applying a fixed height/width and overflow: hidden; to the parent div. You can then add extra padding or height/width to the original element to, essentially, push the scrollbar out of view.
Mark Otto tweeted about the issue back in June 2016. Here is an example of his workaround: https://output.jsbin.com/lohiga.
The basic idea goes something like this:
<header>
<div> <!-- parent wrapper added -->
<nav>
First link
Link
Link
Link
Link
Link
Link
Link
Last link
</nav>
</div>
</header>
CSS:
header {
margin: 20px 0;
padding: 10px 5px;
text-align: center;
background-color: #f5f5f5;
border-bottom: 1px solid #ddd;
}
// Parent wrapper
div {
height: 30px;
overflow-y: hidden; // "crop" the view so the scrollbar can't be seen
}
// Original scrollable element
nav {
padding-bottom: 20px; // extra padding to push the scrollbar out of view
overflow-x: auto;
text-align: center;
white-space: nowrap;
-webkit-overflow-scrolling: touch;
}
nav a {
display: inline-block;
padding: 5px 10px;
}

Related

Unable to get Toolbar fixed at the top of the rich text area with content/body scrollable

The intent is to have the ckEditor toolbar fixed at the top while being able to scroll through the content. Currently, toolbar gets scrolled off the screen as shown in the GIF image below.This component is on a page that is scrollable. So the position:fixed; does not work as I tried that.
The label Question Stem stays at the top and is wrapped by Vuetify Toolbar component.
the ck-toolbar class on the toolbar items has the following CSS
.ck.ck-toolbar {
align-items: center;
display: flex;
flex-flow: row nowrap;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
I have added the following CSS to make the content scrolable.
#ckEditorQuestionStem .ck.ck-toolbar > .ck-toolbar__items {
position: relative !important;
z-index: 10;
}
#ckEditorQuestionStem .ck.ck-editor__main {
max-height: 400px;
overflow-y: auto;
position: relative !important;
}
The HTML for this is shown in the screenshot below
I tried the method posted here. Also tried adding viewportTopOffset: 50, under toolbar of the editor config. No luck so far.
I reolved this by applying the following style on the parent element of ckEditor
style="contain: content;"
And keeping the toolbar position as fixed.
#ckEditorQuestionStem .ck.ck-toolbar > .ck-toolbar__items {
position: fixed !important;
margin-right: 5px;
margin-left: -6px;
min-height: 100px;
top: 0px;
z-index: 2;
}
Posting the answer in case someone finds it helpful. Here is the current editor window with scrollable body and fixed toolbar. This is more desirable than a sticky toolbar.
This was helpful in arriving at the solution.

Hide vertical scrollbar whilst remaining scrollable

I want the vertical scrollbar for my div to be invisible, but still allow vertical scrolling.
I've tried using overflow-y: hidden but that disables scrolling.
I've tried webkit element::-webkit-scrollbar but that affects horizontal scrollbars too.
I would have thought that webkit's :vertical state would allow me to do it but it doesn't do anything. See codepen: (https://codepen.io/numberjak/pen/MWgOMqd)
Other questions look at BOTH scrollbars, I just care about ONE scrollbar.
<div class="scroll"><div class="large-content"/></div>
.scroll {
overflow: auto;
max-width: 20rem;
max-height: 20rem;
background-color: black;
}
.scroll::-webkit-scrollbar:vertical {
display: none;
}
.large-content {
min-width: 100rem;
min-height: 100rem;
background-color: red;
}
Try this css code..
css
.large-content {
background-color: red;
width: 100%;
height: 100%;
}
You can do the following to hide scrollbars:
-webkit- (Chrome, Safari, newer versions of Opera):
.scoll::-webkit-scrollbar { width: 0 !important; }
-moz- (Firefox):
.scroll { overflow: -moz-scrollbars-none; }
-ms- (Internet Explorer +10):
.scroll { -ms-overflow-style: none; }
Important points to be considered before hiding the scroll bar:
Preferably hide scrollbars only if and when all content is visible else the user may skip the content.
Avoid horizontal scrolling on web pages and do not hide horizontal scroll bar as they can make content difficult to read
If at all, hiding scroll is required: Display all important information above the fold. Users may often decide if they want to stay or not on what they can see without scrolling.
Reference

How to hide scroll bar without using overflow "hidden"?

image1
in this image, there is no scroll bar but if I scroll down inside diagram component div element scrollbar will occur
image2 with scrollbar
how can I hide that scrollbar without setting overflow: hidden
references
Just use the CSS of it like that:
selector-with-overflow::-webkit-scrollbar {
width: 10px;
visibility: hidden;
display: none;
}
notice doesnt work on all browsers but should work on the most common ones
I'm not sure why you'd ever want to hide the indication that a page is overflowing, see this JSFiddle: http://jsfiddle.net/2nT38/868/ for the css for a scrollbar that isn't visible yet still scrollable. Here's the breakdown:
::-webkit-scrollbar {
-webkit-appearance: none;
}
::-webkit-scrollbar:vertical {
width: 0px;
}
::-webkit-scrollbar:horizontal {
height: 0px;
}
Hope this helps!

How can I enable vertical web page scrolling from within a horizontally scrollable area in mobile WebKit?

We have the following HTML:
<div class="thumb-list">
<ul class="thumb-list__inner">
<li class="thumb">...</li>
<li class="thumb">...</li>
<li class="thumb">...</li>
...
</ul>
</div>
And CSS:
.thumb-list {
position: relative;
margin-bottom: 1em;
}
.thumb-list__inner {
margin-bottom: 0;
margin-left: 0;
border-radius: 5px;
overflow-x: auto;
white-space: nowrap;
font-size: 0;
}
.thumb {
width: 75px;
display: inline-block;
vertical-align: top;
white-space: normal;
margin-right: 20px;
cursor: pointer;
font-size: 0.9375rem;
}
This produces a horizontal list of items that extends beyond the edge of the viewport which is then scrollable horizontally to reveal more items.
This all works great, except in mobile Webkit browsers, where you can scroll the list horizontally but if you try to scroll the page vertically from within this element, you can't. If you scroll the page from any other element outside this, it's fine. The browser versions I've tested in are:
Chrome 45.0.2454.89 on iOS 9.0.2
Safari on iOS 9.0.2
Default browser on Android 4.2.2
Chrome 5.2.604591 on Android 4.2.2 (this won't scroll in any direction)
I have never encountered this issue before when using this method. The minimal information I've managed to find about this issue suggests that the browser is preventing scrolling in one axis when scrolling is explicitly defined on the other axis.
I've tried using libraries like iScroll but this wouldn't solve the issue.
I'm considering rewriting the functionality to use a carousel plugin or something similar. I'd rather not, as the CSS solution is the simplest. But at this stage I just need it to work!
Has anyone experienced and remedied this issue themselves?

how to enable scrolling rather than squashing divs together

on my website it is a div based layout when the window is reszied everything is pushed together. Such as images overlap or are moved below each other and divs also overlap each other.
How can I get it to scroll when the content of the div is greater than the window size, similar to facebook if you resize the window it prevents anything overlappting and just makes the user scroll?
body
{
background-color: #B0B0B0;
color: #ffffff;
margin-top: 0px;
margin: 0px;
}
#header
{
width: 100%;
height: 100px;
margin: 0px;
padding: 0px;
}
#content
{
width: 80%;
height: 800px;
margin-top: 50px;
margin-left: auto;
margin-right: auto;
padding: 30px;
}
<div id="header">
[Header]
</div>
<div id="content">
[Content]
<img src="image1.png" /><img src="image2.png"/><img src="image3.png" />
</div>
The html is like that but obviously with more content
Hope I haven't made this too confusing, thanks.
Just add overflow:auto; to your div.
You can also use the following if you only want x or y scrolling
overflow-x:auto;
or
overflow-y:auto;
use the overflow:scroll; to enable scrolling in the DIVs
You must add white-space:nowrap; to your body tag.
I believe you may want overflow: auto;
Here's a comparison between auto and scroll.
add the style
overflow: scroll;
to #content
This answer is pretty late, however I stumbled across this question, as I was having issues on one of my pages, where I have this Page with 30 odd inputs of various types, that are split between two tables. I was unable to scroll to see about 10 or so inputs at the bottom of the page, and could not even scroll left to right when adjusting the browsers width.
What solved my issue was:
html, body {
overflow: visible;
}
This activated my X and Y scroll bar.
I had an issue with my footer not adjusting when scrolling, it instead would just stay fixed where it was situated before scrolling. this was due to my master CSS having the footer's position set as absolute. Simple fix, just creating a new style element in the page and added
footer {
position: fixed;
min-width: 100%;
}
I hope this helps anyone looking for a solution.
As stated by user3726345 , the best option to use is the
html,body {
overflow: visible;
}
using
overflow: auto;
dosnt give the best output. then you can further adjust your footer codes to your taste.