Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Agnes Caringal
Agnes Caringal
6,239 Points

Overlapping Divs

I want to overlap the divs with relative position...

div1 have a background have an image which i want to overlap to div2. yet the only way to do this is to make div2 an absolute div. yet after I resolved it div2 have a newsletter form inside yet it's not working since the area of div1 is overlapping...

If there is only way to overlap relative positions using z-index too..

I really need help thanks!!!

2 Answers

Colin Bell
Colin Bell
29,679 Points

Have you tried using negative margins? Are you trying to do something like this: codepen

Agnes Caringal
Agnes Caringal
6,239 Points

It helped a lot thanks also Colin below also helped thanks a lot.. I understand everything when I saw codepen.

Mitchell Springer
Mitchell Springer
2,576 Points

z-index can't actually overlap divs. All it controls is how the divs are layered once they are overlapping. As Colin said, the way to do it would be to use negative margins, and then use z-index to get the overlapped divs in the order you want.