Site logo

[Resolved] Add border to some images

Home Forums Support [Resolved] Add border to some images

Home Forums Support Add border to some images

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1987189
    Amiria

    Hi there,

    I would like to apply a border to some images within posts and pages.

    I tried adding the following as custom CSS, and then gave the image block the CSS class of image-borders, but it didn’t seem to work.

    .image-borders img {
    border-color: #ffcd00;
    border-width: 10px;
    }

    Any help most appreciated. Thank you!

    #1987307
    Leo
    Staff
    Customer Support

    Hi there,

    Your current method should work.

    Try this CSS instead:

    .wp-block-image img.image-borders {
        border-color: #ffcd00;
        border-width: 10px;
    }

    Adding CSS: https://docs.generatepress.com/article/adding-css/

    If this doesn’t work, can you link me to a post where this method is applied?

    Let me know ๐Ÿ™‚

    #1988786
    Amiria

    Thanks Leo.

    I’ve added the CSS with the SiteOrigin CSS plugin, and then added image-borders in the ‘Additional CSS class(es)’ section for the image block when editing the post. The border doesn’t appear to be showing up so far. I’ve added a link in the private section below – see the green image near the top of the post.

    Thanks!

    #1988827
    Ying
    Staff
    Customer Support

    Hi Amiria,

    Your CSS is missing the border-style in order to make the border to show, try this CSS

    .wp-block-image.image-borders img {
        border-color: #ffcd00;
        border-width: 10px;
        border-style: solid;
    }

    Or we can simplify the CSS to 1 line:

    .wp-block-image.image-borders img {
        border: 10px solid #ffcd00;
    }

    Let me know ๐Ÿ™‚

    #1988838
    Amiria

    Awesome, thank you so much! ๐Ÿ™‚

    #1988840
    Ying
    Staff
    Customer Support

    No problem ๐Ÿ™‚

    #1988858
    Amiria

    Oh, sorry, one more question! This now causes images to jut out 20px wider than the text (i.e. the width of the border causes the image to extend beyond the width of the column). Is there a way to keep the image+border perfectly aligned with the edges of the column? New example linked below. Thank you!

    #1988864
    Ying
    Staff
    Customer Support

    Yes, you can add one more line to the CSS, it will become this ๐Ÿ™‚

    .wp-block-image.image-borders img {
        border: 10px vsolid #ffcd00;
        box-sizing: border-box;
    }
    #1988873
    Amiria

    Brilliant, thank you! Worked perfectly. ๐Ÿ™‚

    #1988984
    Ying
    Staff
    Customer Support

    You are welcome ๐Ÿ™‚

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