• I had set up Gutenberg buttons on my site on various older versions of WordPress. On one of my sites, the buttons are no longer centered on desktop view. They are aligned to the left. Example code is:

    <div class="wp-block-button aligncenter"><a class="wp-block-button__link has-background" style="background-color:#c75300" href="xyz" target="_blank" rel="noopener">xyz</a></div>

    On top of this, I can’t horizontally center new buttons in 5.7, even after selecting “justify content centre”.

Viewing 9 replies - 16 through 24 (of 24 total)
  • Thread Starter Paul

    (@pbgeneral)

    Most of my buttons are using code from an old version of Gutenberg that doesn’t look the same as that.

    You’re a developer. If there isn’t already a GitHub page for this, maybe we could start one. Hopefully this is something that will be fixed for the 5.7.1 update.

    I saw this worked for people elsewhere. It worked for me with the twentytwentyone theme but sadly not with twentytwenty which I use a lot. So frustrated by this since update.

    .hentry .entry-content .wp-block-button {
    text-align: center !important

    TheTJ

    (@measuringflower)

    Exact same issue (tjstaste.com). Nothing I’ve tried yet has worked.

    • This reply was modified 3 years, 7 months ago by TheTJ.
    Thread Starter Paul

    (@pbgeneral)

    The solution provided here (https://amethystwebsitedesign.com/button-alignment-in-wordpress-5-7/?cn-reloaded=1) worked for me. A million thanks to this person because I would have been in the dark otherwise.

    I was hoping that this issue would be fixed in the 5.7.1 update, but it seems it was not. So, now I have to add a custom CSS band-aid to fix this issue. I should NOT have to permanently add custom CSS because a WordPress update has made a previous feature (buttons) obsolete. Some websites have hundreds or even thousands of pages — they can’t just go back and edit every single one because a WordPress update broke a previously working feature.

    Over a month, and not one person has stopped by to help with this issue. Unbelievable.

    Just add this class to your button, or modify one of its existing classes (thanks @crispaor, it can indeed be risky to simply override .aligncenter):

    .my-centered-class {
        display: flex;
        justify-content: center;
    }
    • This reply was modified 3 years, 7 months ago by ashtonmv.
    • This reply was modified 3 years, 7 months ago by ashtonmv.

    @ashtonmv be careful. Applying tags to that class can modify other content. It happened to me. Better change that name.

    I agree with Alex… I tried the same thing adding justify-content: center.

    You need justify-content if using display: flex
    text-align if using display: block;

    • This reply was modified 3 years, 7 months ago by kruddock.

    I am facing the same situation as well. Here is my site – https://fitfab50.com

    Most of my posts utilize buttons, but I have been able to overcome this issue by using the Custom HTML block and inserting standard button html, like this…

    <center><button>Type anchor text here</button></center>

Viewing 9 replies - 16 through 24 (of 24 total)
  • The topic ‘Buttons no longer centered’ is closed to new replies.