Home › Forums › Support › Remove space between one line of text and a specific image using WP block editor
- This topic has 11 replies, 3 voices, and was last updated 3 years, 7 months ago by
Fernando.
-
AuthorPosts
-
September 22, 2022 at 8:35 pm #2351194
Trish
Hi,
The image is labeled as wp-image-2853 and I tried to remove the space between one line of text and the image by adding the following code to the Additional CSS text box found under Appearance > Customize… but it didn’t work.
.wp-image-2853 { margin-top: 0!important; }Would like to have this work across the entire website where this image is used repeatedly.
Can you please help me?
Thank you in advance,
TrishSeptember 22, 2022 at 9:02 pm #2351210Fernando Customer Support
Hi Trish,
The margin is in the
<figure>tag. You can try adding a class to the Image, and then use that class instead to target the figure.September 23, 2022 at 6:28 am #2351597Trish
Hi Fernando,
But… I’ve understood that the figure tag is for ALL images and I only want one specific image targeted like this. By adding a class to the image’s “figure”, would that not cause ALL images to remove the space?
September 23, 2022 at 11:06 am #2351899Ying
StaffCustomer SupportBy adding a class to the image’s “figure”, would that not cause ALL images to remove the space?
Correct. If you add a class to the image block, and your CSS is using that class, then you will only target this specific image block.
September 23, 2022 at 11:08 am #2351900Trish
Hey Ying,
But… then I’d need to add that class to EVERY post that image appears on… right?
September 23, 2022 at 12:10 pm #2351946Ying
StaffCustomer SupportAre those images the same file?
If so, you can target the image title, using something like this:
img[title="the-title"] { your CSS here; }September 23, 2022 at 2:05 pm #2352011Trish
Hi Ying,
If you mean the title as is shown in the Media Library… I tried that… even cleared the cache, but that too did not work. 🙁
Thank you for trying.
September 24, 2022 at 11:04 am #2352644Ying
StaffCustomer SupportIt seems WP image block doesn’t include the title attribute to the image and the margin top is added to the figure tag.
Maybe try this, instead of setting the figure’s margin-top to
0, we set the image’s margin-top to a negative value to do an offset.img[alt="photo of Trish with her name below that"] { margin-top: -0.5em !important; }September 24, 2022 at 4:57 pm #2352840Trish
Still no difference… 🙁
September 25, 2022 at 6:27 pm #2353566Fernando Customer Support
I can see it working from my end. Can you try changing the value? Something like:
img[alt="photo of Trish with her name below that"] { margin-top: -1.5em !important; }September 25, 2022 at 8:07 pm #2353628Trish
BIG HUGS for you Fernando, you did it!
THANK YOU!!!!!!!!!!!!!!!!!!!!September 25, 2022 at 8:14 pm #2353631Fernando Customer Support
You’re welcome Trish! Have a nice day!
-
AuthorPosts
- You must be logged in to reply to this topic.