tags:

views:

125

answers:

4

I have this Xul file:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://greenfox/content/mycss.css" type="text/css"?>

<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;

    <image class="Front" src="images/loading.gif"/>
    <image class="Back" src="images/plasma.jpg"/>

</window>

with this CSS (updated):

.Back {
    position: absolute;
    left: 0px;
    top:0px;
    z-index:0;
}

.Front {
    position: absolute;
    left: 0px;
    top:0px;
    z-index:1;
}

and, for some reason, the images are vertically one above another, not in z-index as specified by my CSS. Any idea how to fix it?

workaround

For while, I'm using a new window with no background and no borders, and the "loading" in the center.

+1  A: 

The elements are still positioned relatively to one another you need to position absoutely

.Back {
    position: absolute;
    left: 0px;
    top:0px;
    z-index:0;
}

.Front {
    position: absolute;
    left: 0px;
    top:0px;
    z-index:1;
}
John Hartsock
Thank, but is still with the same behavior.
Tom Brito
+2  A: 

edit: got it :D without ugly margin hacks

<bulletinboard>
    <image src="images/loading.gif" style="top:0px; left:0px; z-index:1"/>
    <image src="images/plasma.jpg" style="top:0px; left:0px; z-index:0"/>
</bulletinboard>

--old solution below--

this seems to work:

.Front {
    position: absolute;
    left: 0px;
    top:0px;
    z-index:1;
    width: 200px;
    height: 200px;
    margin-bottom: -200px;
}

.Back {
    position: absolute;
    left: 0px;
    top:0px;
    z-index:0;
    width: 200px;
    height: 200px;
}
y34h
Yes, it works.. =) Becouse of the margin-bottom. But it works just with a specified size.. How do I make it for a variable height??
Tom Brito
I doubt you can get over requiring dimensions of some sort. You might want to try using `min-height: 20px;`. Change `20px` to whatever you expect the smallest height to be.
sholsinger
Hi, I'm backing to research about it now. With your new solution only the plasma.jpg image is showing here.
Tom Brito
A: 

usually, for css absolute positioning, an element's container also has to have a position not set to static; i'd assume xul is no different, so i suggest styling the window element to have a relative position.

Alex Rosario
A: 

Some implementations of layout engines just deal with strict positive values for z-index.

Just try incrementing each value by 1.

.Back {
    position: absolute;
    left: 0px;
    top:0px;
    z-index:1;
}

.Front {
    position: absolute;
    left: 0px;
    top:0px;
    z-index:2;
}

Another try should be setting your window element to position:relative (this is another CSS gotcha, because one element should be absolutely positioned relatively to a relative element. I know it is confusing, but worth a quick try).

EDIT:

window {
position: relative;
}

.Back {
    position: absolute;
    left: 0px;
    top:0px;
    z-index:1;
}

.Front {
    position: absolute;
    left: 0px;
    top:0px;
    z-index:2;
}
Dave
The positive try didn't work. Can you show in your example how would be the relative thing?
Tom Brito
Check edit for example on relative/absolute positioning (yes, it is that simple, but still worth a try).
Dave
Nothing.. just the margin-bottom from @y34h answer works, but I'll not work with a fixed size..
Tom Brito