父和子选择器使用

时间:2014-06-21 07:33:05

标签: jquery css

如何让父母在孩子下面?

<div class="largezindex">
   <span>mgmg</span>
   <span>mgmg</span>
   <span class="smallzindex">mgmg</span>
</div>

CSS

  .largezindex{
     zindex:1000;
     position:relative;
     hieght:300px;
     backgorund-color:#f0f0f0;
     color:red;
     width:300px;
   }

   .smallzindex{
      z-index:1;
      position: absolute;
  text-align: center;
  top: -25px;
  }

2 个答案:

答案 0 :(得分:3)

如果您想根据孩子的父母选择孩子。你应该像这样使用它

parent child {
   // properties here...
}

在你的情况下,它就像这样

.largezindex .smallzindex {
   // smallzindex properties here...
}

答案 1 :(得分:1)

<强> jquery的

$('.smallzindex').parent(); // will give u the parent of smallzindex
$('.smallzindex').parent().eq(number); // will give u nth parent of child
相关问题