How can i hide (Let it be on the page somewhere and the user shouldnt see it) a div using some tricks with Z-Index ? I dont want to put style="display:none;" to the div to hide it.

Any thoughts ?

2 answers

danwellman 5600

Does it have to be z-index? I'm sure it can be done, try setting your outer container to z-index:0; then the div you want to hide as z-index:-1; and make sure the div is not inside the container, but position it to be behind the container. You'll probably come accross issues in IE however, because of it's broken support for z-index.

You could use visibility:hidden; to hide it instead of display:none;

Or you could put in into your main container - just say the container has a width of, e.g. 960px, set the overflow on the container to hidden and relatively position it, then set the div you want to hide to left:-5000px or some other equally high number, which should render it invisible...

I all depends on why you are trying to hide it..?

Answered almost 7 years ago by danwellman

To do it in accessible way, use CSS to move it far off to the left.

Answered almost 7 years ago by Anthony Grace