Modal z-index over external content peeks through?
I'm creating a modal dialog using jQuery. The code inserts jQuery into the site by means of a bokmarklet, and runs a script that creates a modal dialog. The problem is that some site content always seems to peek through the gray modal, even in Chrome or Firefox. Is there a way to get around it?
The gray 开发者_如何学JAVApart in the bottom is the modal. The logo peeks through.
Do you have a modal overlay and a modal window? I would set your z-index on them extremely high. Since it sounds like you are adding HTML into existing sites, it's hard to say what elements they have set a z-index to and at what level, so best bet it set your z-index to something like 100000.
The trick is to make every dom object on the client page to have a z-index of 1, or lower than the z-index of the modal. Some browsers take into consideration the relative differences of z-indices, so that is crucial.
$("div").each(function() {
$(this).css("z-index", "1");
});
works nicely.
精彩评论