引用:
原帖由 zcfg 于 2008-3-12 22:54 发表 
……
其实,IE下,z-index为负值的层确实是在body下的。大概是因为body的默认背景色是transparent(我猜的,alert出来的为空),html的默认背景色是白色,而z-index为负值的层在他们之间,造成该层看起来依然在body之上的假象。
那么,为什么怿飞前辈的那个例子中,FF下z-index为负值的层没有显示呢?仔细看看我的这个例子的css ,你会发现我在body的定义中加上一句似乎无关痛痒的“opacity:0.99;”。就是这一句,使得我的例子中z-index为负值的层在FF下能显现。至于为什么,我也不知道。囧。我只是发现,只要正确设定了FF下的透明度(1除外),FF下z-index为负值的层就能显现。若设置opacity=1(小于0和大于1的情况不考虑)或不设置opacity,即使设置body的background-Color:transparent,FF下z-index为负值的层也不会显示。
IE的困惑解决了,FF下却出现了小小的困惑,呵呵。
——也许这个“小小的困惑”不是你想要表达的问题之一。
引用:
原帖由 zcfg 于 2008-3-13 13:45 发表 
……
可见,IE和FF下的body的position既不为relative也不是absolute。body没有设置position属性或者说是static。
……
可以发现,html元素有position的属性,但是absolute还是relative不能确定,因为只通过子元素是无法确定父元素的position是absolute还是relative的,只能确定有没有设置父元素position:relative或position:relative。
@macji:
如果body有绝对定位,那么body下的绝对定位就也会相对body进行定位,这个你也自己可以测试。所以我说通过子元素只能确定父元素是否定义position:relative/absolute,而不能确定是二者中的哪一个。
以上均未考虑position:fixed。
——再来看看你表达的这个分析结论:
CSS2:
9.3.1 选择定位方案:'position'属性
'position'和'float'属性指定选择哪个CSS2定位方案来计算框的定位。
'position'
值: static | relative | absolute | fixed | inherit
初始值: static
适用于: 所有元素,除了生成的内容
可否继承: 否
百分比: N/A
媒介: 图形
9.8.4 绝对定位
最后,我们考虑绝对定位的效果。考虑如下的outer和inner的CSS声明:
#outer {
position: absolute;
top: 200px; left: 200px;
width: 200px;
color: red;
}
#inner { color: blue }
这就使outer框的顶的定位基于它的包含块。定位框的包含块由最靠近的定位的前辈创建(或者,如果不存在这样的前辈,则采用
初始包含块,在本例中即为如此)。outer框的顶部在包含块顶部 '200px'之下,左边在包含块左边'200px'。outer框的子框的排列相对于outer框正常排列。
再用一个参考(XHTML标签默认样式基本是基于这个规范的,所以我也只能说作为参考了)来尝试证明一下你的结论
——
Appendix D. Default style sheet for HTML 4:
This appendix is informative, not normative.
This style sheet describes the typical formatting of all HTML 4 ([HTML4]) elements based on extensive research into current UA practice. Developers are encouraged to use it as a default style sheet in their implementations.
The full presentation of some HTML elements cannot be expressed in CSS 2.1, including replaced elements ("img", "object"), scripting elements ("script", "applet"), form control elements, and frame elements.
For other elements, the legacy presentation can be described in CSS but the solution removes the element. For example, the FONT element can be replaced by attaching CSS declarations to other elements (e.g., DIV). Likewise, legacy presentation of presentational attributes (e.g., the "border" attribute on TABLE) can be described in CSS, but the markup in the source document must be changed.
html, address,
blockquote,
body, dd, div,
dl, dt, fieldset, form,
frame, frameset,
h1, h2, h3, h4,
h5, h6, noframes,
ol, p, ul, center,
dir, hr, menu, pre { display: block }
li { display: list-item }
head { display: none }
table { display: table }
tr { display: table-row }
thead { display: table-header-group }
tbody { display: table-row-group }
tfoot { display: table-footer-group }
col { display: table-column }
colgroup { display: table-column-group }
td, th { display: table-cell }
caption { display: table-caption }
th { font-weight: bolder; text-align: center }
caption { text-align: center }
body { margin: 8px }
h1 { font-size: 2em; margin: .67em 0 }
h2 { font-size: 1.5em; margin: .75em 0 }
h3 { font-size: 1.17em; margin: .83em 0 }
h4, p,
blockquote, ul,
fieldset, form,
ol, dl, dir,
menu { margin: 1.12em 0 }
h5 { font-size: .83em; margin: 1.5em 0 }
h6 { font-size: .75em; margin: 1.67em 0 }
h1, h2, h3, h4,
h5, h6, b,
strong { font-weight: bolder }
blockquote { margin-left: 40px; margin-right: 40px }
i, cite, em,
var, address { font-style: italic }
pre, tt, code,
kbd, samp { font-family: monospace }
pre { white-space: pre }
button, textarea,
input, select { display: inline-block }
big { font-size: 1.17em }
small, sub, sup { font-size: .83em }
sub { vertical-align: sub }
sup { vertical-align: super }
table { border-spacing: 2px; }
thead, tbody,
tfoot { vertical-align: middle }
td, th { vertical-align: inherit }
s, strike, del { text-decoration: line-through }
hr { border: 1px inset }
ol, ul, dir,
menu, dd { margin-left: 40px }
ol { list-style-type: decimal }
ol ul, ul ol,
ul ul, ol ol { margin-top: 0; margin-bottom: 0 }
u, ins { text-decoration: underline }
br:before { content: "\A" }
:before, :after { white-space: pre-line }
center { text-align: center }
:link, :visited { text-decoration: underline }
:focus { outline: thin dotted invert }
/* Begin bidirectionality settings (do not change) */
BDO[DIR="ltr"] { direction: ltr; unicode-bidi: bidi-override }
BDO[DIR="rtl"] { direction: rtl; unicode-bidi: bidi-override }
*[DIR="ltr"] { direction: ltr; unicode-bidi: embed }
*[DIR="rtl"] { direction: rtl; unicode-bidi: embed }
@media print {
h1 { page-break-before: always }
h1, h2, h3,
h4, h5, h6 { page-break-after: avoid }
ul, ol, dl { page-break-before: avoid }
}
最后,请楼主原谅我的愚笨——在我之前的回复中,原以为不需要再引用这些啰嗦的规范了
[
本帖最后由 zbm2001z 于 2008-3-14 10:36 编辑 ]