position 属性和 z-index 属性对页面节点层级影响的例子

原文

position 属性和 z-index 属性对页面节点层级影响的例子

该页面的内容是对文章《 CSS z-index 使用方法和层级树 》的补充, 举例说明 position 属性和 z-index 属性对页面节点层级影响.

不设 z-index 属性

例 1.1

A{}

B{}
frameborder="0" marginwidth="0" marginheight="0" src="http://www.neoease.com/tutorials/z-index/1.1.html" style="width: 175px; height: 150px;"> 例 1.2

A{
  position:static;
}

B{}
frameborder="0" marginwidth="0" marginheight="0" src="http://www.neoease.com/tutorials/z-index/1.2.html" style="width: 175px; height: 150px;"> 例 1.3

A{
  position:relative;
}

B{}
frameborder="0" marginwidth="0" marginheight="0" src="http://www.neoease.com/tutorials/z-index/1.3.html" style="width: 175px; height: 150px;">
例 1.4

A{
  position:absolute;
}

B{}
frameborder="0" marginwidth="0" marginheight="0" src="http://www.neoease.com/tutorials/z-index/1.4.html" style="width: 175px; height: 150px;"> 例 1.5

A{
  position:eixed;
}

B{}
frameborder="0" marginwidth="0" marginheight="0" src="http://www.neoease.com/tutorials/z-index/1.5.html" style="width: 175px; height: 150px;"> 例 1.6

A{}

B{}

A-1{
  position:relative;
}
frameborder="0" marginwidth="0" marginheight="0" src="http://www.neoease.com/tutorials/z-index/1.6.html" style="width: 175px; height: 150px;">

单层节点

例 2.1

A{
  z-index:2;
}

B{
  z-index:1;
}

C{
  z-index:0;
}
frameborder="0" marginwidth="0" marginheight="0" src="http://www.neoease.com/tutorials/z-index/2.1.html" style="width: 175px; height: 200px;"> 例 2.2

A{
  z-index:2;
}

B{
  position:relative;
  z-index:1;
}

C{
  position:relative;
  z-index:0;
}
frameborder="0" marginwidth="0" marginheight="0" src="http://www.neoease.com/tutorials/z-index/2.2.html" style="width: 175px; height: 200px;"> 例 2.3

A{
  z-index:1;
}

B{
  position:relative;
  z-index:0;
}

C{
  position:relative;
}

D{
  position:relative;
  z-index:0;
}
frameborder="0" marginwidth="0" marginheight="0" src="http://www.neoease.com/tutorials/z-index/2.3.html" style="width: 175px; height: 200px;">

双层节点

例 3.1

A{
  position:relative;
  z-index:1;
}

A-1{}

B{
  position:relative;
  z-index:0;
}

B-1{}
frameborder="0" marginwidth="0" marginheight="0" src="http://www.neoease.com/tutorials/z-index/3.1.html" style="width: 175px; height: 200px;"> 例 3.2

A{
  position:relative;
  z-index:0;
}

A-1{
  position:relative;
  z-index:2;
}

B{
  position:relative;
  z-index:0;
}

B-1{
  position:relative;
  z-index:1;
}
frameborder="0" marginwidth="0" marginheight="0" src="http://www.neoease.com/tutorials/z-index/3.2.html" style="width: 175px; height: 200px;"> 例 3.3

A{
  position:relative;
  z-index:2;
}

A-1{
  position:relative;
  z-index:0;
}

B{}

B-1{
  position:relative;
z-index:1;
}
frameborder="0" marginwidth="0" marginheight="0" src="http://www.neoease.com/tutorials/z-index/3.3.html" style="width: 175px; height: 200px;">

多层节点

例 4.1

A{
  position:relative;
  z-index:0;
}

A-1{
  position:relative;
  z-index:100;
}

B-1{
  position:relative;
  z-index:0;
}

B-1-1{
  position:relative;
  z-index:10;
}

C-1-1{
  position:relative;
  z-index:0;
}

C-1-1-1{
  position:relative;
  z-index:1;
}
frameborder="0" marginwidth="0" marginheight="0" src="http://www.neoease.com/tutorials/z-index/4.1.html" style="width: 175px; height: 200px;"> 例 4.2

A{
  position:relative;
  z-index:0;
}

A-1{
  position:relative;
  z-index:100;
}

B-1{
  position:relative;
}

B-1-1{
  position:relative;
  z-index:10;
}

C-1-1{
  position:relative;
  z-index:0;
}

C-1-1-1{
  position:relative;
  z-index:1;
}
frameborder="0" marginwidth="0" marginheight="0" src="http://www.neoease.com/tutorials/z-index/4.2.html" style="width: 175px; height: 200px;"> 例 4.3

A{
  position:relative;
  z-index:0;
}

A-1{
  position:relative;
  z-index:100;
}

B-1{}

B-1-1{
  position:relative;
  z-index:10;
}

C-1-1{
  position:relative;
  z-index:0;
}

C-1-1-1{
  position:relative;
  z-index:1;
}
frameborder="0" marginwidth="0" marginheight="0" src="http://www.neoease.com/tutorials/z-index/4.3.html" style="width: 175px; height: 200px;">
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值