CSS - 添加缩进不适用于嵌套ul li

时间:2015-10-30 12:16:50

标签: html css

我是CSS的新手,我想为ul - li添加一些父级ul.optiongroup的额外间距。但是那些ul.optiongroup还可以包含更多ul.optiongroupli s。所以。这是html看起来像[Pl.see my old query for reference if required]和JsFiddle

NESTED UL-LIs

<div id="target" class="treeselector">
  <div class="styledSelect">
    Select
  </div>
  <ul class="optiongroup expand" rel="Home">
    <li class="title">
      <span>&nbsp;</span>Home
    </li>
  </ul>
  <ul class="optiongroup expand" rel="Products">
    <li class="title">
      <span class="fa fa-minus-square-o">&nbsp;</span>Products
    </li>
    <li rel="PCPROducts1" class="expand">
      PCPROducts1
    </li>
    <li rel="PCPROducts5" class="expand">
      PCPROducts5
    </li>
    <ul class="optiongroup expand" rel="PCPROducts6">
      <li class="title">
        <span class="fa fa-plus-square-o">&nbsp;</span>PCPROducts6
      </li>
      <ul class="optiongroup" rel="6th Product">
        <li class="title">
          <span class="fa fa-plus-square-o">&nbsp;</span>6th Product
        </li>
        <li rel="Digital">
          Digital
        </li>
        <li rel="Analog">
          Analog
        </li>
      </ul>
    </ul>
  </ul>
 </div>

试图像这样添加CSS:

.optiongroup li{
  margin-left:40px;
  border:  1px red solid; /* Just to see what's happening there */
}
  • 我怎样才能做到这一点?
  • 设置ul - li最简单的css最简单的方法是什么。

1 个答案:

答案 0 :(得分:1)

如果不需要,你会使用很多UL标签。

您可以尝试这样做:

autodoc

请注意,第二个UL在LI内部