My Community Pro Theme Setup

  1. Home
  2. Docs
  3. My Community Pro Theme Se...
  4. Extras
  5. After WP5.7 – Center Buttons Using CSS

After WP5.7 – Center Buttons Using CSS

WordPress 5.7 changed the CSS class that it adds to center buttons.

​The is a change in WordPress 5.7, and affects the classes on all previously added buttons.
This means that any buttons you centered or right-aligned in an earlier version of WordPress will probably no longer be centered or right-aligned.

1. You can edit each button to center it again, and this will add the correct CSS class, and the buttons will be centered again.

2. But if you don't have time to edit all your buttons, you can add the following to Appearance > Customize > Additional CSS:

/* Fix for WP5.7 buttons class changes to use flexbox */
.wp-block-buttons.aligncenter {
	    justify-content: center;
}
.wp-block-buttons.alignleft {
	    justify-content: flex-start;
}
.wp-block-buttons.alignright {
	    justify-content: flex-end;
}

We've also added the CSS needed for left and right aligned buttons, in case you've used them, as well.