Jump to content

How to make CSS calc() function work on Custom CSS editor?

Go to solution Solved by paul2009,

Recommended Posts

Hi,

I have a custom html list whose items I try to show in three columns with flexbox. List items have padding to add room for item background.

li {
  flex: 0 0 calc(33% - 66px);
  padding: 0 16px 0 50px;
  background:  url('check.png') no-repeat left top;
}

The problem is that squarespace has some kind of preprocessor which converts calc() to this: (style copied from browsers inspector)

flex: 0 0 calc(-33%);

How should I write calc() to keep it in the desired format?

Link to comment
  • Solution

@Jfer00 This is because the 'Custom CSS' panel is actually the 'Custom LESS' panel 😁.

Any math operations in brackets are calculated first (33-66=-33) and then the CSS parsed. You can avoid this by using escaping it like this:

  flex: 0 0 calc(~"33% - 66px");

 

About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥.
Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. 
Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links.
Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional.

Link to comment
  • 1 year later...

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.