Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Negative margin, z-index and click blocking

Tags:

html

css

z-index

I'm using negative margins to layout two columns:

<div id="left-column"><input type="checkbox" /></div>
<div id="right-column">
    <div id="right-column-inner"></div>
</div>

Css:

#left-column { width: 200px; float: left;}
#right-column { margin-left: -200px; width: 100%; float: left;}
#right-column-inner { margin-left: 200px; float: left;}

Unfortunately, in Opera 10.54, Safari 4 and FF 3+, the checkbox isn't clickable as the #right-column is capturing the click before it propogates down to the checkbox.

I've tried manipulating the z-index but no luck.

Any idea how to get this to work?

like image 269
EoghanM Avatar asked Jun 28 '10 14:06

EoghanM


1 Answers

When you change a positioning property in CSS (such as top, left, bottom, right or z-index) you have to specify a position property other than static (the default).

So change the z-index and the position CSS properties.

#left-column { width: 200px; float: left; position:relative; z-index:100;}
like image 169
Richard JP Le Guen Avatar answered Sep 30 '22 06:09

Richard JP Le Guen