白云岛资源网 Design By www.pvray.com
XML/HTML Code复制内容到剪贴板
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3.     <head>  
  4.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
  5.         <meta name="author" content="Chomo" />  
  6.         <link rel="start" href="http://www.14px.com" title="Home" />  
  7.         <title>法则五:非同辈元素,任意一者或其祖元素拥有动态定位时,同时各自向上寻找动态定位的祖元素,并分别从中拿出具备最高级别的祖元素(或其本身)进行比较。</title>  
  8.     </head>  
  9.     <style type="text/css">  
  10.         div { font:12px/1.5 arial;}   
  11.         div strong { color:#fff; background:#036; display:inline-block;}   
  12.         h3 strong { color:#f00;}   
  13.         /*--- 定义方块外形 ---*/   
  14.         .div1,   
  15.         .div2 {   
  16.             height:70px;   
  17.             width:150px;   
  18.             background:#cff;   
  19.             border:1px solid #036;   
  20.         }   
  21.         .grandDiv1,   
  22.         .grandDiv2 {   
  23.             padding:10px;   
  24.             border:1px solid #060;   
  25.             width:174px;   
  26.             background:#cf9;   
  27.         }   
  28.         .parentDiv1,   
  29.         .parentDiv2 {   
  30.             padding:10px;   
  31.             border:1px solid #f06;   
  32.             width:152px;   
  33.             background:#fcf;   
  34.         }   
  35.         /*--- 定义方块偏移位置、文字位置 ---*/   
  36.         .grandDiv2 {   
  37.             margin-top:-50px;   
  38.             margin-left:95px;   
  39.         }   
  40.         .parentDiv2 {   
  41.             margin-top:-40px;   
  42.             margin-left:85px;   
  43.         }   
  44.         .div2 {   
  45.             margin-top:-20px;   
  46.             margin-left:75px;   
  47.             padding-top:30px;   
  48.             height:40px;   
  49.         }   
  50.         .grandDiv2 .parentDiv2,   
  51.         .grandDiv2 .div2,   
  52.         .parentDiv2 .div2 { margin:0;}   
  53.     </style>  
  54.     <body>  
  55.         <h3>法则五<strong>(重要)</strong>:非同辈元素,任意一者或其祖元素拥有动态定位时,同时各自向上寻找动态定位的祖元素至共有的祖元素的下一级为止,并分别从中拿出具备最高级别的祖元素(或其本身)进行比较。</h3>  
  56.         <p>情况1:子元素的z-index无论多大,父元素大者居上。<p>  
  57.             <div class="parentDiv1" style="position:relative; z-index:2;">  
  58.                 .parentDiv1{position:relative;<strong>z-index:2</strong>}   
  59.                 <div class="div1">.div1{position:static}</div>  
  60.             </div>  
  61.             <div class="parentDiv2" style="position:relative; z-index:1;">  
  62.                 <div class="div2" style="position:relative; z-index:10000;">.div2{position:relative;<strong>z-index:10000</strong>}</div>  
  63.                 .parentDiv2{position:relative;<strong>z-index:1</strong>}   
  64.             </div>  
  65.         <p>情况2:父元素居下,子元素也可以居上。<p>  
  66.         <div class="parentDiv1">  
  67.             .parentDiv1{position:staitc}   
  68.             <div class="div1" style="position:relative;">.div1{position:relative}</div>  
  69.         </div>  
  70.         <div class="parentDiv2">  
  71.             <div class="div2">.div2{position:staitc}</div>  
  72.             .parentDiv2{position:staitc}   
  73.         </div>  
  74.         <p>情况1、情况2结合扩展比较。<p>  
  75.         <div class="grandDiv1" style="position:relative; z-index:3;">  
  76.             .grandDiv1{position:relative;<strong>z-index:3</strong>}   
  77.             <div class="parentDiv1">  
  78.                 .parentDiv1{position:staitc}   
  79.                 <div class="div1" style="position:relative; z-index:10000;">.div1{position:relative;<strong>z-index:10000</strong>}</div>  
  80.             </div>  
  81.         </div>  
  82.         <div class="grandDiv2">  
  83.             <div class="parentDiv2" style="position:relative; z-index:4;">  
  84.                 <div class="div2">.div2{position:staitc}</div>  
  85.                 .parentDiv2{position:relative;<strong>z-index:4</strong>}   
  86.             </div>  
  87.             .grandDiv2{position:static;}   
  88.         </div>  
  89.     </body>  
  90. </html>  
白云岛资源网 Design By www.pvray.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
白云岛资源网 Design By www.pvray.com