Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

div under another div

Tags:

html

css

with css, can I put a div under another div without using absolute positioning?

I have these two divs, and I would like the solid white one to appear directly under the one with the yellow opacity (but not direct in the corner, at the corner of the outline).

How can this be accomplished. I've been experimenting with z-index and relative positioning, but to no avail.

Thanks http://jsfiddle.net/loren_hibbard/WtGsv/

like image 682
1252748 Avatar asked Jul 29 '26 02:07

1252748


1 Answers

Without using positioning, I added a style to your content div using negative margins:

.content {
    margin-top:-100px;
}

Working demo here: http://jsfiddle.net/WtGsv/3/

I suggest adding an id to your .fixed_width div which houses the .content div though, and using the id to give the negative margin to, that way the parent div has the negative margin, not the child div.

However if you want to use absolute positioning, I have updated your jsfiddle here: http://jsfiddle.net/WtGsv/12/

Basically, you add a parent div with position:relative; around your other two divs that you want to use position:absolute;

like image 177
Andy Avatar answered Jul 30 '26 15:07

Andy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!