Jump to content

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

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
  • Replies 4
  • Views 2.7k
  • Created
  • Last Reply

@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");

 

Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥.
Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. 
Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links.
Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional.

Would you like your customers to be able to mark their favourite products in your Squarespace store?

Link to comment
  • 1 year later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.