0

我不知道我的解释是否正确,但我有一个特定类的 div。在 div 里面,我有一个带有 id 的 ul - 我正在尝试设置该 ul 的样式。

这将更好地证明它:

<div class="parent">
     <ul id="child">
          <li>
          </li>
     </ul>
</div>

<style type="text/css" media="screen">
.parent #child li{float:left;}
.parent #child{margin-bottom:54px;}
</style>

以上将不起作用,我找不到正确的方法。我试过.parent > #child了,它仍然不起作用。

先谢谢了。

4

3 回答 3

0

Here's a fiddle showing this working with a couple of css tweaks: http://jsfiddle.net/4RJKk/

Follow this code and you should be golden.

.parent {
    overflow:auto;
}
.parent #child li {
    float:left;
}
.parent #child{
    margin-bottom:54px;
}


<div class="parent">
     <ul id="child">
          <li>test</li>
          <li>test</li>
     </ul>
</div>

here
于 2012-11-26T11:06:04.060 回答
0

现在定义你的孩子 overflow:hidden

像这样

.parent #child{overflow:hidden;}

现场演示

于 2012-11-26T10:51:05.173 回答
0

你可以ul#child在你的css中使用这个。基本上它的作用是检查你的 UL 的那个 id。我不认为父母应该重要,因为您只会使用一次 ID。如果你想让它被更多地使用,那就让它成为一个类。

于 2012-11-26T10:52:00.163 回答