如何针对最后一个孩子

War*_*sse 1 css sass

似乎无法定位我的3divs中的最后一个p-tag.我想删除的边框last-child的的p-标签.我在这做错了什么:

      <div class="box">
        <div class="span4">
          <p>Some text.</p>
        </div>
        <div class="span4">
          <p>Some text.</p>
        </div>
        <div class="span4">
          <p>Some text.</p>
        </div>
      </div>      


.span4 {
    width: 320px;
    p {
        font-size: 1.2em;
        padding: 0 40px;
        border-right: 1px #dfdfdf solid;
    }
    &:last-child {
        border: none;
    }
}
Run Code Online (Sandbox Code Playgroud)

Don*_*uwe 6

您需要p使用伪选择器选择标记:

.span4 {
    width: 320px;
    p {
        font-size: 1.2em;
        padding: 0 40px;
        border-right: 1px #dfdfdf solid;
        &:last-child {
            border: none;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)