Connecting Tech Pros Worldwide Forums | Help | Site Map

How can I make a div topmost?

Warren Tang
Guest
 
Posts: n/a
#1: Sep 17 '08
Hi

How can I make a div (position relative) topmost? I tried the z-index,
but no matter how I set it, some portion of the div is always covered.

Any tips or suggestions? Thanks in advance.

Regards
Warren

Chris F.A. Johnson
Guest
 
Posts: n/a
#2: Sep 17 '08

re: How can I make a div topmost?


On 2008-09-17, Warren Tang wrote:
Quote:
Hi
>
How can I make a div (position relative) topmost? I tried the z-index,
but no matter how I set it, some portion of the div is always covered.
Don't position other elements over it.

--
Chris F.A. Johnson <http://cfaj.freeshell.org>
================================================== =================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Ben C
Guest
 
Posts: n/a
#3: Sep 17 '08

re: How can I make a div topmost?


On 2008-09-17, Warren Tang <warren_tang@sina.comwrote:
Quote:
Hi
>
How can I make a div (position relative) topmost? I tried the z-index,
but no matter how I set it, some portion of the div is always covered.
It must be then that the div is covered by its own descendents.
Quote:
Any tips or suggestions? Thanks in advance.
When you set z-index on a div it does two things: moves the div itself
in its stacking context (i.e. puts it behind or in front of some other
elements), and starts a new stacking context inside the div for its own
descendents.

Because it starts that new stacking context whatever you do with z-index
on its descendents is limited to rearranging them among themselves. None
of them can be made to jump lower in the stack that the original div nor
higher than the next thing in front of it in its stacking context.

You will have the finest control if you set z-index on elements nearest
to the leaves of the document tree. That way you can keep all the
elements you're interested in rearranging in the same stacking context
as each other and all the little nested stacking contexts you create
have little or nothing in them.

So you might be better not to set z-index on the div itself, but instead
to set negative z-indices on the things that are on top of it to move
them behind it.
Johannes Koch
Guest
 
Posts: n/a
#4: Sep 18 '08

re: How can I make a div topmost?


Warren Tang schrieb:
Quote:
How can I make a div (position relative) topmost? I tried the z-index,
but no matter how I set it, some portion of the div is always covered.
By plugin content like flash?

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
dorayme
Guest
 
Posts: n/a
#5: Sep 18 '08

re: How can I make a div topmost?


In article <48d20448$0$13388$6e1ede2f@read.cnntp.org>,
Johannes Koch <koch@w3development.dewrote:
Quote:
Warren Tang schrieb:
>
Quote:
How can I make a div (position relative) topmost? I tried the z-index,
but no matter how I set it, some portion of the div is always covered.
>
By plugin content like flash?
Don't even think about it. Ben C gave an excellent answer.

--
dorayme
Daniel Jung
Guest
 
Posts: n/a
#6: Sep 18 '08

re: How can I make a div topmost?


dorayme wrote:
Quote:
In article <48d20448$0$13388$6e1ede2f@read.cnntp.org>,
Johannes Koch <koch@w3development.dewrote:
>
>
Quote:
>>Warren Tang schrieb:
>>
>>
Quote:
>>>How can I make a div (position relative) topmost? I tried the z-index,
>>>but no matter how I set it, some portion of the div is always covered.
>>
>>By plugin content like flash?
>
Don't even think about it.
That was maybe not a solution, but a reason.

- Daniel
Warren Tang
Guest
 
Posts: n/a
#7: Sep 18 '08

re: How can I make a div topmost?


Unfortunately, it was covered by other divs created by myself.

Daniel Jung wrote:
Quote:
dorayme wrote:
Quote:
>In article <48d20448$0$13388$6e1ede2f@read.cnntp.org>,
> Johannes Koch <koch@w3development.dewrote:
>>
>>
Quote:
>>Warren Tang schrieb:
>>>
>>>
>>>How can I make a div (position relative) topmost? I tried the
>>>z-index, but no matter how I set it, some portion of the div is
>>>always covered.
>>>
>>By plugin content like flash?
>>
>Don't even think about it.
>
That was maybe not a solution, but a reason.
>
- Daniel
Warren Tang
Guest
 
Posts: n/a
#8: Sep 18 '08

re: How can I make a div topmost?


Hi Ben

Thank you! I am trying to understand the "stacking context".

Regards
Warren

Ben C wrote:
Quote:
On 2008-09-17, Warren Tang <warren_tang@sina.comwrote:
Quote:
>Hi
>>
>How can I make a div (position relative) topmost? I tried the z-index,
>but no matter how I set it, some portion of the div is always covered.
>
It must be then that the div is covered by its own descendents.
>
Quote:
>Any tips or suggestions? Thanks in advance.
>
When you set z-index on a div it does two things: moves the div itself
in its stacking context (i.e. puts it behind or in front of some other
elements), and starts a new stacking context inside the div for its own
descendents.
>
Because it starts that new stacking context whatever you do with z-index
on its descendents is limited to rearranging them among themselves. None
of them can be made to jump lower in the stack that the original div nor
higher than the next thing in front of it in its stacking context.
>
You will have the finest control if you set z-index on elements nearest
to the leaves of the document tree. That way you can keep all the
elements you're interested in rearranging in the same stacking context
as each other and all the little nested stacking contexts you create
have little or nothing in them.
>
So you might be better not to set z-index on the div itself, but instead
to set negative z-indices on the things that are on top of it to move
them behind it.
Daniel Jung
Guest
 
Posts: n/a
#9: Sep 19 '08

re: How can I make a div topmost?


Warren Tang wrote:
Quote:
Unfortunately, it was covered by other divs created by myself.
we are still waiting for a url.

- Daniel
Closed Thread