As for preventing scrolling on the div, all you need to apply on the footer is overflow: hidden; and that should do the trick. Actually margin:0 auto; is not going to help with position:absolute;.
A quick fix is to add overflow: hidden to the CSS for your #footer . Note: A scrollbar will still appear if your #body content flows out of the the viewport. Show activity on this post. It will remove unnecessary scroll bars.
Notice that 'overflow:hidden' is in the HTML file of the embedded element. Show activity on this post. Use your embed tag inside a container with overflow hidden. Then set the width of the embed with 100% + 17px (the default width of a scrollbar).
overflow-x: hidden;
Don't forget to write overflow-x: hidden;
The code should be:
overflow-y: scroll;
overflow-x: hidden;
overflow-y: scroll;
See it on jsFiddle.
Notice if you remove the -y
from the overflow-y
property, the horizontal scroll bar is shown.
With overflow-y: scroll
, the vertical scrollbar will always be there even if it is not needed. If you want y-scrollbar to be visible only when it is needed, I found this works:
.mydivclass {overflow-x: hidden; overflow-y: auto;}
Add this code to your CSS. It will disable the horizontal scrollbar.
html, body {
max-width: 100%;
overflow-x: hidden;
}
To hide the horizontal scrollbar, we can just select the scrollbar of the required div and set it to display: none;
One thing to note is that this will only work for WebKit-based browsers (like Chrome) as there is no such option available for Mozilla.
In order to select the scrollbar, use ::-webkit-scrollbar
So the final code will be like this:
div::-webkit-scrollbar {
display: none;
}
No scroll (without specifying x or y):
.your-class {
overflow: hidden;
}
Remove horizontal scroll:
.your-class {
overflow-x: hidden;
}
Remove vertical scroll:
.your-class {
overflow-y: hidden;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With