- This topic has 9 replies, 3 voices, and was last updated 4 years, 7 months ago by
Ying.
-
AuthorPosts
-
November 1, 2021 at 1:36 pm #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!
November 1, 2021 at 6:07 pm #1987307Leo
StaffCustomer SupportHi 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 ๐
November 2, 2021 at 12:51 pm #1988786Amiria
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!
November 2, 2021 at 1:33 pm #1988827Ying
StaffCustomer SupportHi Amiria,
Your CSS is missing the
border-stylein 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 ๐
November 2, 2021 at 1:42 pm #1988838Amiria
Awesome, thank you so much! ๐
November 2, 2021 at 1:43 pm #1988840Ying
StaffCustomer SupportNo problem ๐
November 2, 2021 at 2:02 pm #1988858Amiria
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!
November 2, 2021 at 2:07 pm #1988864Ying
StaffCustomer SupportYes, 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; }November 2, 2021 at 2:15 pm #1988873Amiria
Brilliant, thank you! Worked perfectly. ๐
November 2, 2021 at 5:25 pm #1988984Ying
StaffCustomer SupportYou are welcome ๐
-
AuthorPosts
- You must be logged in to reply to this topic.