last-child of div class

前端 未结 4 1217
孤独总比滥情好
孤独总比滥情好 2021-02-06 00:43

I am finishing some Wordpress web page and I want to style (with CSS) the roll of entries in the Posts page. Wordpress creates this:

         


        
相关标签:
4条回答
  • 2021-02-06 00:49

    You've already named what you're looking for: last-child: http://reference.sitepoint.com/css/pseudoclass-lastchild

    So use .entry:not(:last-child) { border-bottom: 1px solid yellow; }

    Note that it´s not a list so I can´t use pseudo-classes)

    JSYK, the pseudoclass does not depend on the containing element being a list. If you meant that the final .entry element is not actually the last child of its container, it may still be possible to select it. But I can't tell you how unless you show me what the actual markup looks like.

    If your final div.entry is not followed by any other divs, then the selector .entry:not(:last-of-type) will work for you.

    0 讨论(0)
  • 2021-02-06 00:56

    For the most comprehensive browser support, I would recommend using this:

    .entry { border-bottom: 1px solid yellow; }
    .entry:last-child { border-bottom: 0; }
    
    0 讨论(0)
  • 2021-02-06 01:09
    .entry:last-child {
      border-bottom: none;
    }
    

    Let's say you have a list <li> with links <a> inside, and you want to get that last <a> of the <li>'s. Just use:

    .entry:last-child a {
      border-bottom: none;
    }
    

    This will select the last of the .entry and target it's link(s)

    0 讨论(0)
  • 2021-02-06 01:12

    Pretty simple solution:

    #wrapper :last-child
    {
        border:none;
    }
    
    0 讨论(0)
提交回复
热议问题