Why is the z-index style not applied to the <body> element?
The style z-indexallows you to control which order fields are colored. For example, you can create a child below its parent:
#parent {
background: rgba(33, 33, 33, 0.7);
}
#child {
width: 100px;
height: 100px;
background: yellow;
position: relative;
z-index: -1;
}<div id="parent"><div id="child"></div></div> However, when the parent is a tag <body>, it no longer behaves as expected:
body {
background: rgba(33, 33, 33, 0.7);
}
#child {
width: 100px;
height: 100px;
background: yellow;
position: relative;
z-index: -1;
}<body>
<div id="child"></div>
</body>The CSS specification §9.9.1 states (primary focus):
. ( ), "z-index", "auto". . CSS , 'opacity [CSS3COLOR].
:
- , .
- ( ).
- , -, - .
- .
- inline, inline-level, .
- 0 0.
- ( ).
<body> , , , <body> , .
HTML <html> . , <body> z-index?
, html , body, . CSS 2.1 :
, HTML- HTML XHTML "html", "transparent" "background-color" "none" "background-image", HTML "BODY" "body" XHTML, .
, , html :
, , , , Ian Hickson Tantek Celik, CSS.
W3C, spec z-index body.
:
Tantek Celik:
z-index: . , BODY (. )?
z-index.
z-index.< BODY STYLE = "z-index: 0; background-color: # 456789;" > < < P STYLE = "z-index: -1; color: #fedcba;" > , , <EM> ( "z-index" "-1" ). </EM>
</ >,
z-index, , :http://www.w3.org/TR/REC-CSS2/visuren.html#z-index
z-index " : ",
z-index.Tantek
:
,
(: ,
z-index, , , , , - .):
< body style = "z-index = 0; background-color = green;" >
< p style = "z-index = -1; position: relative; top: 50; left: 20" > !! </ >
< > !! </ >
</ >P BODY, CSS2 ( , :) z- -, . z- .
"!" "!!" BODY, BODY P .
!!! , , , , , , , .!!!
()
z-index=-1aposition: fixed( .) , , , , , BODY.- ranjit
:
,
, .
HTML. , / .
: , (XML, HTML,...)
: z- . , . , , ,....
, CSS2, , z- ..
, z- CHILD z-. , , z-, z- .
: - , , , , .
,
- ranjit
http://lists.w3.org/Archives/Public/www-style/1999Aug/0131.html
The <body>default tag remains at the bottom of the stack. It simply cannot be installed, as it will always be the smallest possible value.
Source: Adobe Forums