Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browsers scrollbar is under my fixed div

i have a fixed header with 100% width.

#header {
background: #2e2e2e;
width: 100%;
z-index: 999;
position: fixed;
}

browsers scrollbar is under my fixed div. How to fix that?

scrollbar

like image 391
LifeIsShort Avatar asked Oct 23 '12 10:10

LifeIsShort


People also ask

How do I get rid of unnecessary scrollbar?

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.

How do I get the scroll bar inside a div?

For vertical scrollable bar use the x and y axis. Set the overflow-x:hidden; and overflow-y:auto; that will automatically hide the horizontal scroll bar and present only vertical scrollbar. Here the scroll div will be vertically scrollable.

How do I fix the scroll bar in CSS?

The easy fix is to use width: 100% instead. Percentages don't include the width of the scrollbar, so will automatically fit. If you can't do that, or you're setting the width on another element, add overflow-x: hidden or overflow: hidden to the surrounding element to prevent the scrollbar.

How do I get rid of overflow scrollbar?

To hide the horizontal scrollbar and prevent horizontal scrolling, use overflow-x: hidden: HTML.


3 Answers

its because the overflow-x: hidden; in base.css line number 9

body {
    color: #444444;
    font: 13px/20px Arial,Helvetica,sans-serif;
    overflow-x: hidden; // remove this 
}
like image 137
NullPoiиteя Avatar answered Oct 08 '22 04:10

NullPoiиteя


This can be solved by adding overflow of body

from

overflow:auto;

to

overflow:auto;
overflow:initial;

This is your issue

If your scroll is set on body, if its structured as body > wrapper > header (with fixed position), content so on

below is your solution

solution for issue

note: this will work only on body but not on div container with scroll. you can also work with z-index to get it to work, but you will be specifying z-index to stack other elements in order to get it right.

Hope this helps..:)

like image 44
mike tracker Avatar answered Oct 08 '22 03:10

mike tracker


The issue isn't with overflow-x on the body tag. It's because of overflow-x andoverflow-y on the html tag. Once I removed this from the HTML tag, I could put whatever overflow I wanted on my body.

This happens when:

  • overflow-x is set to either auto, hidden, overflow, or scroll
  • overflow-y is set to either auto, hidden, -webkit-paged-x, or -webkit-paged-y

It doesn't have to be an explicit call to overflow-x or overflow-y, as overflow sets both of them.

I'm on Chrome 67 using Windows 10.

like image 15
NonameSL Avatar answered Oct 08 '22 04:10

NonameSL