CSS code for spacing under image

  • Hello,

    There is no spacing between images I add to my blog post and the text coming after. How can I add an automated spacing under (I assume using CSS as ChatGPT generated below but it does not work) image block.

    I want to add the spacing for images (Generatepress block and Gutenberg) BUT NOT featured image.

    Thanjks,

    
    /* Spacing below image */
    .entry-content .wp-block-image img,
    .entry-content img.wp-image {
      margin-bottom: 40px;
      display: block;
    }
    
  • Hi there,

    Could you please share the URL of the page where you want the spacing applied?

    That way, I can inspect the setup and give you the exact steps to add spacing under your images without affecting the featured image.

  • I want to apply to the entire site not a specific site. See the example below please.

  • Also, I want all the images added as “image” block centered horizontally as it is aligned on the left at the moment. Is this also possible?

    Thanks,

  • Hi there,

    Please try this CSS under Appearance → Customize → Additional CSS:

    /* Spacing applied */
    main .wp-block-image {
    margin-bottom: 40px;
    }
    
    /* Center images */
    main .wp-block-image img {
    display: block;
    margin-inline: auto;
    }

    The first CSS applies the spacing, and the second centres the images.

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