Can not target the last child of an element

I want to disable border-bottom of the last elemnt inside a while loop, but it doesn’t work…
This is the code:

<div class="col-sm-4">  
        <?php if ( $the_query->have_posts() ): ?>
        <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>                                   
          <h2 class="special-project-title"><?php the_title()?></h2> <br/>
         <div class="post-meta special-project-meta"><?php mida_post_meta()?></div><br/>
         <a class="more-link spaciel-project-more" href="<?php echo the_permalink() ?>"><?php echo __('Read More', 'mida')?></a><br/>
    <?php endwhile; endif;?>    
    <?php wp_reset_query(); ?>  
</div>

“spaciel-project-more” has a border bottom, but I want the last one to not have a border bottom.. can’t figure this out..

Read More

CSS:

.spaciel-project-more{
    border-bottom: 1px solid black;
    margin-top: -15px;
    margin-bottom: -15px;
    padding-bottom: 15px;
}
.spaciel-project-more:last-child{
    border-bottom:none;
}

Thanks in advance!

Related posts

2 comments

  1. It is not the :last-child because there is some other content after that. You can use :last-of-type:

    .spaciel-project-more:last-of-type {
      border-bottom: 0
    }
    

    Demo: JSFiddle

  2. use this in your style in css may help you

    .spaciel-project-more:last-child{
        border-bottom:0px;
    }
    

Comments are closed.