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

Z-index issue

Hello,

Please visit the site I'm working on @ :

http://everythingpropertymanagement.com

On the top of the home page you will see a Google Custom Search bar - if you type in something to search then you will notice a pop-up window appears but that the logo is showing up on top of the search pop up, and also the 'X' to close the pop-up doesn't worked when at the top of the page -

Any ideas on how to fix this? Is it a z-index issue? I've tried this but nothing worked.

Thanks for any help!

Hey Brandon,

I'm having a bit of trouble understanding your issue. Could you do your best to clarify? It may also help attaching a marked-up screenshot of your site for reference.

Chris

3 Answers

Hey Brandon,

So I've spent quite a bit of time fooling around in the dev tools in your site. While i haven't found the answer to your problem, I believe I've pinpointed the general cause.

First and foremost, the logo isn't the only thing stacked on top of your overlay; if you scroll down the page, it seems to be that every image and graphic is doing this. In my opinion, this is a result of multiple "stacking contexts" existing on your page. z-index and opacity are far more complicated concepts than they appear to be on the surface, and they work in concert with each other and position to produce different "stacking contexts" along the z-axis.

I'm far from an expert on the nuances of the subject, but you can get a gist for them via this blog post from Phillip Walton.

I came to this conclusion by first fooling around with the positioning, opacity and z-indices of the elements and their parents. No change. Then, I physically took the entire overlay div and moved it to the top of your main-wrapper, essentially making it the first real element on your page. Why did I do this? Because the default stacking order is (more or less) the same as the order of appearance in the HTML. So i knew that if I put your overlay at the top, and it stacked itself on top of the graphics, the issue would indeed be one of stacking context "pollution", that is a bit too pervasive throughout your page for a simple z-index modification to resolve.

Mind you, I very well could have missed something, but I definitely gave it a fair shake. My advice would be to start from a baseline; set the position, z-index, and opacity properties of most, if not all elements on the page, to defaults, then build up from there a bit at a time. It will be much easier than unscientifically hacking at it like I did.

Also, try to scale back on the use of the !important keyword, because it's pretty notorious for overriding specificity in ways you may not have anticipated.

Good luck!

Chris

Thank you Chris - seems like a lot of work, you're right. I appreciate your time!

As far as the x that appears on the popped up window, that's probably related to a javaScript issue. Do you have an event listener attached to that button?

@ Nathan Brenner: I don't know what an event listener is - The search bar is created through Google Custom Search...

@Christopher Aporta: So if you go to the site (http://everythingpropertymanagement.com) and you search for something in the search bar when the pop-up window shows up our logo is overlaying on top of the pop-up window. I want the logo to be behind the pop-up window....

Below is a screenshot - (hopefully it comes up)

alt text