Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.