Support » Fixing WordPress » Different CSS for widgets depending on their count

  • Hi!

    I’m working on a footer that has four widgets next to each other, each with a CSS making them 25% wide to fill the whole width. The problem I have with this, however, is that if I choose to (for example) only have three widgets, they don’t fill the whole width unless I tweak the CSS again (and I don’t want to do this). So… Is there any way to have the CSS of the widgets change depending on how many widgets I am using? E.g. if I have one widget, it’s 100% wide, if I have two, they’re both 50% etc.

    I currently have this code in the functions.php:

    remove_filter('get_the_excerpt', 'wp_trim_excerpt');
    add_filter('get_the_excerpt', 'improved_trim_excerpt');
    if ( function_exists('register_sidebar') ) {
    	'before_widget' => '<div class="%1$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3>',
            'after_title' => '</h3>'

    Bare in mind that I am extremely stupid when it comes to PHP or coding in general, so I really need “PHP for dummies” kind of explanations 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Different CSS for widgets depending on their count’ is closed to new replies.