1

i have a #cover div with the following css

#cover {
    background-color: #FFFFFF;
    height: 100%;
    opacity: 0.4;
    position: fixed;
    width: 100%;
    z-index: 9000;
}

i want it to cover the entire (viewed) page like so

enter image description here

however when i scroll down i see this

enter image description here

thats because a margin of 8 is added to the top and the left.

i tried adding margin:-8 -8 8 8; with no success. why??? and how can i fix this?

DEMO fiddle.

Math chiller
  • 4,123
  • 6
  • 28
  • 44

2 Answers2

1

you fogot to set a position. just add:

top: 0;
left: 0;

since you havn't posted you complete markup, i can only assume your body has a margin or padding causing the shift you're seeing.

oezi
  • 51,017
  • 10
  • 98
  • 115
1

simple thing to fix.

Add that to your CSS

* /*Remove all the default margin and padding*/
{
    margin: 0;
    padding: 0;
}
html, body /*so it'll work when you specify 100% height on element*/
{
    height: 100%;
}

BTW: use units(px/%) for margin/padding other then 0.

and Here's a Fiddle

also, You don't even need the fixed position for that.. check out that fiddle

avrahamcool
  • 13,888
  • 5
  • 47
  • 58