CSS changes for image padding

  • Unknown's avatar

    I’m using the Babylog theme and it has large spaces (padding) above and below images. I was able to find and add code to change the line spacing, but I need some help with the CSS code for changing image padding.
    Thanks!

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar

    Hi Bookmarklit! Love your site. Can you show me an example of where you want the padding to change?

    Also, you may find this helpful in the meantime.

    https://developer.mozilla.org/en-US/docs/Web/CSS/padding

  • Unknown's avatar

    For example, my most recent post has an image that says “Top 10 Tuesday,” and the following line of text is far under it.. even though there are no spaces in between when editing it.

  • Unknown's avatar

    Hi there, we can specifically target that image at the top of your post and reduce the bottom margin on it using the following CSS.

    .wp-image-1663 {
        margin-bottom: 20px;
    }

    If you insert images at the top of all your posts, then each of those would require an additional CSS rule, but there are ways around that. Instead of using the above specific CSS, open that post in the editor, click on the image to highlight it and then click on the edit icon for that image, and then click on “Advanced Options” in the screen that comes up, you can set a bottom margin for that specific image. Make sure and click the “Update” button at lower right after making that change.

  • Unknown's avatar

    It must be an automatic setting that all images have some kind of padding above/below them, because it’s not just the image in that post that I mentioned. I would think that there could be a CSS change I could make that changes the image padding setting on ALL images?

  • Unknown's avatar

    Add this to your custom CSS and let me know how it looks (you can change the 10px amount to whatever you like!):

    .aligncenter {
      margin:10px auto;
    }
  • Unknown's avatar

    That worked nicely! I changed it to 5, but it looks great. thanks :)

  • The topic ‘CSS changes for image padding’ is closed to new replies.