• Hi,
    I want to target last child of an element inside a while loop.
    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>

    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;
    }

    I want in the last “read more” element to disable the border bottom, but it doesnt work.. any help? thanks!

Viewing 1 replies (of 1 total)
  • There is a trailing <br /> after every read-more link, so the last link is never the last element.

    If you use .spaciel-project-more:last-of-type instead, it will use the last a element with that class name.

    Konstantin

Viewing 1 replies (of 1 total)
  • The topic ‘Target last child..why it doesn't working’ is closed to new replies.