Jump to content

Adding border to image make it offset from the wrapper

Recommended Posts

Hi there!

 

I'm trying to add a while border to all images in a specific section. I'm using this code for each blockID

#block-0c00759fd0846c881ded {
    border: 8px solid white;
  padding: -8px;
}

 

The issue is that it's making the image not fit inside the wrapper anymore, which isn't that big of a deal on desktop but on web it means everything is slightly off. See image below.

 

So two questions:

1. How do I set the stroke to align to the inside of the image wrapper so the image stays within the box I've made for it.

2. How do I add it to all images in a section without having to call out each blockID individually 

Screenshot 2023-08-24 at 8.40.18 PM.png

Link to comment

Try this method using a pseudo-element:

#block-0c00759fd0846c881ded:after {
  content:'';
  position:absolute;
  height:100%;
  width:100%;
  background-color:none;
  border:8px solid #fff;
  top:18px;
  right:-30px;
}

Play with the border, top and right values to get the look you want.

Let me know how that works for you.

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 
Hire me on Upwork!

🔌 Ghost Squarespace Plugins (Referral link)
📈 SEO Space (Referral link)
 SquareWebsites Plugins (Referral link)
 🔲 SQSP Themes (Referral link) 
Spark Plugin (Referral link) 
 🖼️ Gallery Lightbox Plugin (Referral link) 

 Did I help? Buy me a coffee?

Link to comment
  • 1 year later...

Thank you for this code. I am trying to create on offset border that is layered behind the image instead of the full border being on top of the image. Is there a way to do this so that the border doesn't actually overlap the image on the top/left side? See attached. Thanks very much!

Screenshot 2024-08-25 at 6.23.52 AM.png

Link to comment
On 8/29/2024 at 3:08 AM, sunicreative said:

Sure. It's definitely a work in progress lol but here you go:

 

mackerel-bamboo-7why.squarespace.com 

password: W3arItAgain

 

Where is this image? I can't find it on Home or About page

https://mackerel-bamboo-7why.squarespace.com/about

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.