Sydney fp latest news center posts when i only have two blog posts

Hi how do I center posts on the sydney fp latest news widget when I only have 2 posts. Now they are aligned to the left.
I’m using the widget twice so I cant use a class to do it.

Thanks,
Martin

Hello Martin,

To achieve such that objective, please follow the steps below:

  1. Install and activate the TC Custom JavaScript plugin
  2. Go To Appearance > Custom JavaScript
  3. Paste the following code into the provided box

;(function($) {

   'use strict'

   if ( matchMedia( 'only screen and (min-width: 768px)' ).matches ) {
   
     var post = $('.sydney_latest_news_widget .panel-widget-style .blog-post');
     
     if( post.length == 2 ) {      
      post.wrapAll('<div class="news-wrap"></div>');
     }

   }

})(jQuery);  

  1. Update

  2. Navigate to Appearance > Customize > Additional CSS. And then add the following custom CSS code:


@media only screen and (min-width:768px) {
   
   .news-wrap {
       display: -webkit-box;
       display: -moz-box;
       display: -ms-flexbox;
       display: -webkit-flex;
       display: flex;
       align-items: center;
       justify-content: center;   
   }   

   .news-wrap .blog-post {
      float: none !important;
   }

}

Regards,
Kharis

Hi,
That worked perfectly.
Thanks,
Martin

Thank you for getting back to me. You’re welcome, Martin.

Please let us know in a new topic if you have any further questions, or if we can provide you with any other assistance.

Regards,
Kharis