I need to display an iframe when a user clicks on a link on header of page. How do I make sure the iframe is always on top of all content? CSS z-indexs don't work effectively in this case.
+2
A:
z-index
probably doesn't work because your iframe
is not a positioned box:
For a positioned box, the 'z-index' property specifies:
- The stack level of the box in the current stacking context.
- Whether the box establishes a local stacking context.
Set its position
to something other than static
. For example:
iframe#myiframe {
z-index: 20;
position: absolute;
}
strager
2009-03-25 22:50:52
A:
z-index only works on positioned content. Either use position:absolute; and top/left/right to position the element or use position:relative; to leave the element where it is.
Either one should enable z-index on the element.
tgecho
2009-03-25 22:53:14
position: absolute; doesn't need top/bottom/left/right. If they are not specified, the box stays put and does not affect the box model (i.e. it stays on top of non-absolute things). Same with relative.
strager
2009-03-25 22:55:09
/smackhead Good point. Somehow I always automatically applied those values, assuming a default of 0 on top/left. Learn something new every day.
tgecho
2009-03-26 01:19:42
A:
The issue I am having is that the position:fixed does not work in IE7. I am wrapping my iframe in a div but that goes behind other content on the page in IE7. Also I cannot modify the properties of the underlying divs. I can only change the property of the new iframe or wrap it in a div. Any other suggestions ?
Iris
2009-03-26 14:58:43