I've implemented a popup box that dynamically displays search options. I want the box to "float" above all of the site content. Currently, when the box is displayed it displaces all of the content below it and looks bad.
I believe I've already tried setting the z-index of the box's div to above that of the remaining page content, but still no luck.
You want to use absolute positioning.
For instance :
To get it to work, the parent needs to be relative (
position:relative
)In your case this should do the trick:
give
z-index:-1
to flash and givez-index:100
to div..Use
To position the div. Make sure it doesn't have a parent tag with position: relative;
Yes, the higher the z-index, the better. It will position your content element on top of every other element on the page. Say you have z-index to some elements on your page. Look for the highest and then give a higher z-index to your popup element. This way it will flow even over the other elements with z-index. If you don't have a z-index in any element on your page, you should give like z-index:2; or something higher.
The results container div has
position: relative
meaning it is still in the document flow and will change the layout of elements around it. You need to useposition: absolute
to achieve a 'floating' effect.You should also check the markup you're using, you have phantom
<li>
s with no container<ul>
, you could probably replace both thediv#suggestions
anddiv#autoSuggestionsList
with a single<ul>
and get the desired result.