3 posts are displayed and under each of them there is a thin 1px border line – the last (3rd) post should not have this border. How to do that?
Code:
<?php
$args = array( 'numberposts' => 3 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<!-- TITLE -->
<div class="proponowanytitle">
<?php the_title(); ?>
</div>
<!-- DATE -->
<div class="proponowanydate">
<?php the_time('m F Y');?>
</div>
<?php endforeach; ?>
CSS:
.proponowanytitle {
color:#34a694;
font-size:13px;
font-weight:400;
padding:15px 0 0 0;
margin:0;
}
.proponowanydate {
color:#999a9b;
font-size:14px;
font-weight:400;
padding:0 0 15px 0;
margin:0;
border-bottom:1px solid #e2e2e3;
}
.proponowanydate:last-child {
color:#999a9b;
font-size:14px;
font-weight:400;
padding:0 0 15px 0;
margin:0;
}
It doesn’t work, i tried :not(:last-child) as well. Can anyone help me set the last-child?
As mentioned in the other comment, you can use the
:last-child
pseudo class. However, you need to make sure the last.proponowanydate
is the last child of it’s parent.To make sure this happens, add in a wrap/container div:
HTML/PHP
CSS
Use the CSS
:last-child
selector after adding a parent element. See here.