[Resolved] Automatically Center Heading in Gutenburg editor

Home Forums Support [Resolved] Automatically Center Heading in Gutenburg editor

Home Forums Support Automatically Center Heading in Gutenburg editor

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #2327554
    Sam

    Hi –

    Is there a way I can automatically have the Gutenberg editor set to format headings and photos in the center? It would save me a ton of time if I didn’t have to go through the whole blog post centering the headings and photos.

    Thanks!
    Sam

    #2327576
    Ying
    Staff
    Customer Support

    Hi Sam,

    Do you want them to be centered on the front end or the back end?

    #2327621
    Sam

    Ultimately the front end for the layout of what the reader sees.

    Thanks,
    Sam

    #2327630
    Ying
    Staff
    Customer Support

    Can you link us to your site? Do you want it to apply to all the posts and pages? Or post only?

    #2327634
    Sam

    All the posts would be great. Site linked below. I have manually centered all photos and headers. My H1 is already automatically centered I should add.

    #2327697
    Ying
    Staff
    Customer Support

    Give this CSS a try:

    .single-post h1, .single-post h2, .single-post h3, .single-post h4, .single-post h5, .single-post h6 {
        text-align: center !important;
    }
    .single-post .entry-content  .wp-block-image {
        text-align: center;
    }
    .single-post .entry-content .wp-block-image img {
        margin-left: auto;
        margin-right: auto;
    }
    #2327762
    Sam

    Where do I add the code please

    #2327782
    Ying
    Staff
    Customer Support

    You can add it to customizer > additional CSS.

    #2328302
    Sam

    That worked, thank you!

    #2328615
    Ying
    Staff
    Customer Support

    Actually try this CSS instead, by using the :is pseudo element, the CSS can be much shorter:

    :is(.single-post) :is(h1,h2,h3,h4,h5,.wp-block-image) {
        text-align: center !important;
    }
    .single-post .entry-content .wp-block-image img {
        margin-left: auto;
        margin-right: auto;
    }
    #2328877
    Sam

    Ive changed it to the above. thanks!

    #2329726
    Ying
    Staff
    Customer Support

    You are welcome 🙂

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.