{"id":2053,"date":"2017-03-24T15:16:13","date_gmt":"2017-03-24T09:46:13","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=2053"},"modified":"2017-03-28T16:33:29","modified_gmt":"2017-03-28T11:03:29","slug":"hiding-scrollbar-html-page","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/hiding-scrollbar-html-page\/","title":{"rendered":"[ Solved &#8211; 10 Answers ] CSS &#8211; HTML &#8211; Hiding the scrollbar on an HTML page"},"content":{"rendered":"<p><label class=\"label label-Warning\">PROBLEM :<\/label><\/p>\n<p>How to Hide the scrollbar on an HTML page using CSS ?<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Html Code<\/span> <\/div> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">&lt;style type=&quot;text\/css&quot;&gt;<br\/>body {<br\/>    overflow:hidden;<br\/>}<br\/>\t\t          &lt;\/style&gt;<\/code><\/pre> <\/div>\n<p><label class=\"label label-info\">SOLUTION 1:<\/label><\/p>\n<ul>\n<li>Set overflow: hidden; on the body tag like this:<\/li>\n<\/ul>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Html code<\/span> <\/div> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">&lt;style type=&quot;text\/css&quot;&gt;<br\/>body {<br\/>    overflow:hidden;<br\/>}<br\/>\t\t          &lt;\/style&gt;<\/code><\/pre> <\/div>\n<ul>\n<li>The code above hides both horizontal and vertical scrollbar.<\/li>\n<\/ul>\n<p>If you want to hide only the vertical scrollbar, use overflow-y:<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Html Code<\/span> <\/div> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">&lt;style type=&quot;text\/css&quot;&gt;<br\/>body {<br\/>    overflow-y:hidden;<br\/>}<br\/>\t\t         &lt;\/style&gt;<\/code><\/pre> <\/div>\n<ul>\n<li style=\"top: 82px;\">And if you want to hide only the horizontal scrollbar, use overflow-x:<\/li>\n<\/ul>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Html Code<\/span> <\/div> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">&lt;style type=&quot;text\/css&quot;&gt;<br\/>body {<br\/>    overflow-x:hidden;<br\/>}<br\/>&lt;\/style&gt;<\/code><\/pre> <\/div>\n<p><label class=\"label label-info\">SOLUTION 2:<\/label><\/p>\n<ul>\n<li>This works for webkit:<\/li>\n<\/ul>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Css code<\/span> <\/div> <pre class=\"language-css code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-css code-embed-code\">#element::-webkit-scrollbar { <br\/>    display: none; <br\/>}<\/code><\/pre> <\/div>\n<ul>\n<li style=\"top: 82px;\">If you want all scrollbars hidden, use<\/li>\n<\/ul>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Css Code<\/span> <\/div> <pre class=\"language-css code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-css code-embed-code\">::-webkit-scrollbar { <br\/>    display: none; <br\/>}<br\/>::-webkit-scrollbar { <br\/>    display: block; <br\/>}<\/code><\/pre> <\/div>\n<p style=\"top: 82px;\">[ad type=&#8221;banner&#8221;]\n<ul>\n<li>You can of course always use width: 0, which can than be easily restored with width: auto.<\/li>\n<\/ul>\n<p><label class=\"label label-info\">SOLUTION 3:<\/label><\/p>\n<ul>\n<li>You can accomplish this with a wrapper div that has it&#8217;s overflow hidden, and the inner div set to auto.<\/li>\n<li>To remove the inner div&#8217;s scroll bar, you can pull it out of the outer div&#8217;s viewport by applying a negative margin to the inner div.<\/li>\n<li>Then apply equal padding to the inner div so that the content stays in view.<\/li>\n<\/ul>\n<h4 id=\"html\"><strong><span style=\"color: #808000;\">HTML<\/span> <\/strong><span style=\"color: #808000;\">:<\/span><\/h4>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Html Code<\/span> <\/div> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">&lt;div class=&quot;hide-scroll&quot;&gt;<br\/>    &lt;div class=&quot;viewport&quot;&gt;<br\/>        ...<br\/>    &lt;\/div&gt;<br\/>&lt;\/div&gt;<\/code><\/pre> <\/div>\n<h4 id=\"css\" style=\"top: 82px;\"><strong><span style=\"color: #800080;\">CSS :<\/span><\/strong><\/h4>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Css Code<\/span> <\/div> <pre class=\"language-css code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-css code-embed-code\">.hide-scroll {<br\/>    overflow: hidden;}<br\/>.viewport {<br\/>    overflow: auto;<br\/>    \/* Make sure the inner div is not larger than the container<br\/>     * so that we have room to scroll.<br\/>     *\/<br\/>    max-height: 100%;<br\/>    \/* Pick an arbitrary margin\/padding that should be bigger<br\/>     * than the max width of all the scroll bars across<br\/>     * the devices you are targeting.<br\/>     * padding = -margin<br\/>     *\/<br\/>    margin-right: -100px;<br\/>    padding-right: 100px;}<\/code><\/pre> <\/div>\n<p><label class=\"label label-info\">SOLUTION 4:<\/label><\/p>\n<ul>\n<li>We can do this :<\/li>\n<\/ul>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Html code<\/span> <\/div> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">&lt;div class=&quot;contentScroller&quot;&gt;<br\/>&lt;div class=&quot;content&quot;&gt;<br\/>&lt;\/div&gt;<br\/>&lt;\/div&gt;<br\/>.contentScroller {overflow-y: auto; visibility: hidden;}<br\/>.content {visibility: visible;}<\/code><\/pre> <\/div>\n<p><label class=\"label label-info\">SOLUTION 5:<\/label><\/p>\n<ul>\n<li>You can use the CSS property overflow and -ms-overflow-style with a combination with ::-webkit-scrollbar.<\/li>\n<li>Tested on IE10+, Firefox, Safari and Chrome and works good:<\/li>\n<\/ul>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Css Code<\/span> <\/div> <pre class=\"language-css code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-css code-embed-code\">.container {<br\/>    -ms-overflow-style: none;  \/\/ IE 10+<br\/>    overflow: -moz-scrollbars-none;  \/\/ Firefox<br\/>}<br\/>.container::-webkit-scrollbar { <br\/>    display: none;  \/\/ Safari and Chrome<br\/>}<\/code><\/pre> <\/div>\n<p style=\"top: 82px;\">[ad type=&#8221;banner&#8221;]\n<ul>\n<li>when you hide the scrollbar with padding-right, because the default scrollbar width is different on each browser.<\/li>\n<\/ul>\n<p><strong>Note<\/strong>: In the latest versions of Firefox the -moz-scrollbars-none property is deprecated ( link ).<\/p>\n<p><label class=\"label label-info\">SOLUTION 6:<\/label><\/p>\n<ul>\n<li>Use css overflow property:<\/li>\n<\/ul>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Css Code<\/span> <\/div> <pre class=\"language-css code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-css code-embed-code\">.noscroll {<br\/>  width:150px;<br\/>  height:150px;<br\/>  overflow: auto; \/* or hidden, or visible *\/<br\/>}<\/code><\/pre> <\/div>\n<p><label class=\"label label-info\">SOLUTION 7:<\/label><\/p>\n<ul>\n<li>Here&#8217;s a jsfiddle, which uses the solution below to hide a horizontal scrollbar.<\/li>\n<\/ul>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Css Code<\/span> <\/div> <pre class=\"language-css code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-css code-embed-code\">.scroll-wrapper{<br\/>    overflow-x: scroll;<br\/>}<br\/>.scroll-wrapper::-webkit-scrollbar { <br\/>    display: none; <br\/>}<\/code><\/pre> <\/div>\n<p><label class=\"label label-info\">SOLUTION 8:<\/label><\/p>\n<ul>\n<li>To disable vertical scroll bar just add : overflow-y:hidden;<\/li>\n<\/ul>\n<p><label class=\"label label-info\">SOLUTION 9:<\/label><\/p>\n<ul>\n<li>Cross Browser Approach to hiding the scrollbar.<\/li>\n<\/ul>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Css Code<\/span> <\/div> <pre class=\"language-css code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-css code-embed-code\">\/* make parent invisible *\/<br\/>#parent {<br\/>    visibility: hidden;<br\/>    overflow: scroll;}<br\/>\/* safari and chrome specific style, don&#039;t need to make parent invisible because we can style webkit scrollbars *\/<br\/>#parent:not(*:root) {<br\/>  visibility: visible;}<br\/>\/* make safari and chrome scrollbar invisible *\/<br\/>#parent::-webkit-scrollbar {<br\/>  visibility: hidden;}<br\/>\/* make the child visible *\/<br\/>#child {<br\/>    visibility: visible;}<\/code><\/pre> <\/div>\n<p><label class=\"label label-info\">SOLUTION 10:<\/label><\/p>\n<h4 id=\"html-2\"><span style=\"color: #808000;\">HTML :<\/span><\/h4>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Html Code<\/span> <\/div> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">&lt;h1&gt;Wikitechy&lt;\/h1&gt;<br\/>&lt;div id=&quot;box&quot;&gt;<br\/>    &lt;div id=&quot;content&quot;&gt;<br\/>        &lt;p&gt;Hi !!! Welcome to Wikitechy&lt;\/p&gt;<br\/>    &lt;\/div&gt;<\/code><\/pre> <\/div>\n<h4 id=\"css-2\" style=\"top: 82px;\"><span style=\"color: #800080;\"><strong>CSS :<\/strong><\/span><\/h4>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Css Code<\/span> <\/div> <pre class=\"language-css code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-css code-embed-code\">h1{font-weight:bold;font-size:2em;} \/* ignore only for header *\/<br\/>\/* *********************** *\/<br\/>div#box{<br\/>    height:200px;    width:300px;  overflow:hidden;<br\/>    border:1px solid black;<br\/>    padding: 10px;}<br\/>div#content{<br\/>    height:200px;<br\/>    width:326px;    \/*<br\/>     * Uncomment to see scrollbar<br\/>    width:300px;    *\/<br\/>    overflow:auto;}<\/code><\/pre> <\/div>\n[ad type=&#8221;banner&#8221;]\n","protected":false},"excerpt":{"rendered":"<p>PROBLEM : How to Hide the scrollbar on an HTML page using CSS ? SOLUTION 1: Set overflow: hidden; on the body tag like this: The code above hides both horizontal and vertical scrollbar. If you want to hide only the vertical scrollbar, use overflow-y: And if you want to hide only the horizontal scrollbar, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,24],"tags":[4379,4394,4384,4381,4387,4388,4389,4391,4393,4380,4392,4382,4386,4385,4378,4383,4390],"class_list":["post-2053","post","type-post","status-publish","format-standard","hentry","category-css","category-html","tag-but-still-being-able-to-scroll","tag-css-hide-horizontal-scrollbar","tag-css-overflow-property","tag-hide-scrollbar","tag-hide-scrollbar-but-still-scroll","tag-hide-scrollbar-chrome","tag-hide-scrollbar-firefox","tag-hide-scrollbar-jquery","tag-hide-scrollbar-when-not-needed","tag-hide-vertical-scrollbar-but-still-scrollable","tag-hide-vertical-scrollbar-css","tag-hiding-vertical-scrollbars-with-pure-css-in-chrome","tag-how-to-disable-scrollbars-on-html-page","tag-how-to-hide-scroll-bar","tag-html-hide-scroll-bar","tag-ie-6","tag-webkit-scrollbar-hide"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/2053","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=2053"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/2053\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=2053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=2053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=2053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}