1

I am trying to make the horizontal scroll bar hidden so that the user cannot scroll . I have read somewhere that my body tag should contain a width of 100% and to set overflow-x:hidden but the following code but I can still scroll a bit on my mobile media query as shown below:

html, body {
   background-color: silver;
   height: 400%;
   width: 100%;
   overflow-x:hidden;

}

enter image description here

piano0011
  • 61
  • 7

1 Answers1

0

Check the example below, I've set the div width to be higher than my window and in the body tag, I remove the scroll using an overflow-x: hidden.

Since I don't have access to your source I can't help much.

HTML

<body>
<div class="scroll">
   <p>Hi</p>
</div>
</body>

CSS

    body {
    overflow-x: hidden;
}

.scroll {
    min-height:800px;
    min-width: 1000px;
}

Working example: FiddleJs Example, note that if you remove the overflow-y the horizontal bar will show up. Maybe you're overwriting the overflow, try to mark it as:

overflow-y: hidden !important

Or open your console and debug in there.

yaKay
  • 115
  • 13
  • I tried it but it doesn't work.... I think there is too much code to add here... Can I post my live website and you can check it on your mobile? – piano0011 Dec 18 '18 at 05:08
  • Yes, go ahead. I'll format your post once we're done in order to help further users. – yaKay Dec 18 '18 at 05:25
  • I am just afraid that some people might register on my site as it is not readied yet – piano0011 Dec 18 '18 at 05:57
  • the thing is that for my mobile version, the user can still scroll to the right a tiny bit – piano0011 Dec 18 '18 at 05:58
  • can you create a div and put all the content inside this div and then do an inline: overflow-x: hidden just to test it. Without the code, I can't debug it. – yaKay Dec 18 '18 at 05:59
  • I have already done that and it still doesn't work...I know that when viewing on the mobile phones on most site, I can't scroll to the right... – piano0011 Dec 18 '18 at 06:15
  • I got it to work because I was using the wrong meta tag for media query... Must I include this on every single page or just my main index.php? – piano0011 Dec 18 '18 at 11:53