div中的Last-Child无效

时间:2015-05-14 06:20:36

标签: html css addthis

我使用addthis共享插件并将背景颜色更改为黄色并添加了bottom-border: of 1px,我想删除最后一个使用以下css不适合我的底部边框

CSS

div#at4-share a:last-child
{
  border-bottom: 0px solid #1f1f1f; 
}

HTML

<div id="at4-share" class="addthis_32x32_style atss atss-left addthis-animated slideInLeft at4-show">
  <a class="at4-share-btn at-svc-facebook" href="#">
    <span class=" at4-icon aticon-facebook" title="Facebook">Facebook</span>
  </a>
  <a class="at4-share-btn at-svc-twitter" href="#">
    <span class=" at4-icon aticon-twitter" title="Twitter">Twitter</span>
  </a>
  <a class="at4-share-btn at-svc-pinterest_share" href="#">
    <span class=" at4-icon aticon-pinterest_share" title="Pinterest">Pinterest</span>
  </a>
  <a class="at4-share-btn at-svc-google_plusone_share" href="#">
    <span class=" at4-icon aticon-google_plusone_share" title="Google+">Google+</span>
  </a>
  <a class="at4-share-btn at-svc-compact" href="#">
    <span class=" at4-icon aticon-compact" title="More">More</span>
  </a>
  <div id="at4-scc" class="at-share-close-control ats-transparent at4-show at4-hide-content" title="Hide">
    <div class="at4-arrow at-left">Hide</div>
  </div>
</div>

我曾尝试过

div#at4-share a:last-of-type
{
  border-bottom: 0px solid #1f1f1f; 
}

所以我不确定是什么问题

2 个答案:

答案 0 :(得分:4)

您需要使用:last-child,因为divdiv#at4-share a:last-of-type {border-bottom: 2px solid red;} ,在这种情况下会隐藏文字。

:last-child

https://jsfiddle.net/4y9j0z9q/

另见{{1}}

https://jsfiddle.net/4y9j0z9q/1/

答案 1 :(得分:2)

正确的选择器是:last-of-type

div#at4-share > a:last-of-type
{
  border-bottom:none; /* To remove the bottom border. */
}

FIDDLE