Blur a background image in Squarespace (and other fun effects)

I have this cool blur effect on the demo page of my Slider that I thought I’d share. Basically it just adds a blur effect to an image, allowing you to do cool things like this:

Screen Shot 2021-04-01 at 2.36.31 PM.png


The blurred background image (largest baby Yoda) is what I’m going to show you how to do. This tutorial will go over adding this effect in Squarespace 7.1, but if you’re on Squarespace 7.0, I have some code for you at the bottom.

Blurring an image is actually quite simple through CSS, all we need to use is the filter property.

This code is adding a filter to the mountain landscape image below it:


img{
  filter:blur(3px);
}

TRY IT OUT!

Change the pixel number in the code to see how it increases and decreases the blur effect. (0px = no blur)

unsplash-image-4y8Z0uz3W68.jpg

Well that’s easy….

So what this CSS is doing is targeting the img element and applying a filter to that image with a value of blur(3px). You might have two questions after seeing this:

  1. How can I target the right element?

  2. What other values could I use instead of blur?

Targeting the background element

The background element of a section in Squarespace 7.1 can be targeted using the .section-background class. I visualize the HTML structure of a section in SS 7.1 like this:

[data-section-id]
.section-background
.section-content

The section is the outer (grey) box, and it contains the two inner (orange and blue) boxes. The first inner (orange) box holds the section background (.section-background) and the next box (blue) holds the section content (.content-wrapper). These two inner sections sit on top of each other. Hit that play button in the top right to see what I mean.

[data-section-id]
.section-background
.section-content

To target the background of a specific section, we first need to target the section, then that section’s background image.

Using the unique data-section-id of that specific section, I can blur the background with this bit of CSS added to our Page Header Code Injection area:


  <style>
  [data-section-id="UNIQUE ID"] .section-background{
    filter: blur(3px) 
  }
  </style>

!! Be sure to switch out the UNIQUE ID text with the unique id of your specific section.

But wait! With some backgrounds, especially colored ones, we get this border around the image. Yuck.

Color Frame-min.jpg

So to get rid of this, just add a transform property with a scale value around 1.1 and adjust as necessary for your background. This will scale up your image so that that colored frame disappears. Your code should now look like this;


  <style>
  [data-section-id="UNIQUE ID"] .section-background{
    filter: blur(3px);transform: scale(1.1);
  }
  </style>

Did you notice?

We're applying this filter to the element, not the image. So this filter property can work for anything you want, not just section background images.

Once you do this, your background section will have a nice little blur effect. If you’re on a Squarespace 7.0 Brine template, scroll down to get code below.

What other values could I use instead of blur?

So why is the code filter:blur(3px) instead of blur:3px;, it’s because we have SO MANY FILTER EFFECTS!! Check out all of our options below:

Filter Value
Accepts
Description
blur()
Pixel Value
filter:blur(3px)
Be careful, things get blurry real fast!
brightness();
Percentage
filter:brightness(120%)
Default is 100% bright.
drop-shadow();
box-shadow type values
filter:drop-shadow(5px 5px 5px black)
this is great to use for png's & svg's. It will actually put a shadow around the content, not the box holding it.
grayscale();
Percentage
filter:grayscale(100%)
This will be fully black and white. Cool for use with hover effects. Be sure your spelling is grayscale, with an 'a', not greyscale.
hue-rotate();
degrees
filter:hue-rotate(90deg)
This will spin each color value 90degrees on a color wheel. Use 180deg to invert the colors.
invert();
Percentage
filter:invert(100%)
Honestly, never really found a use-case for this one. But would love to hear if you use it somewhere!
opacity();
Percentage
filter:opacity(50%)
Apparently, this one has better performace, so maybe start using it? I find the regular opacity property easier to remember though...
saturate();
Percentage
filter: saturate(120%);Regular CSS
filter: ~'saturate(200%)'; SS Custom CSS
Got some dull looking images? Use saturate to pull out the color. Be sure to use the second one in the Custom CSS area of Squarespace.
sepia();
Percentage
filter: sepia(200%);
Get all artsy with this one.

You can also combine them if you want! So something like this would also work:


filter: blur(3px) grayscale(80%);

Best way to learn these is to play around with them, so check out this fun little codepen with a picture of my elderly dog, Hippity Hop, where you can play and adjust to your hearts content. The “Goodest Boy” filter is automatically turned all the way up on this one though.

See the Pen Hippy Filter by Will Myers (@Will-Myers) on CodePen.

If you’re interested in learning more about CSS in Squarespace, check out my Learn CSS in Squarespace course. This course is for people who are serious about their Squarespace Website building and want to level up their skills and/or grow their website building business. I wholeheartedly believe that CSS is the single best skill you can learn if you want to become a better Squarespace designer.

Code for Squarespace 7.0

Squarespace 7.0 Brine Index Page (without Parallax)

Add this code the Index Page Settings » Advanced » Code Injection


  <style>
  #page-url .Index-page-image{
    filter:blur(3px);
    transform:scale(1.1);
  }
  </style>
Squarespace 7.0 Brine Code (with Parallax)

Parallax in 7.0 Brine moves the background images around, so in this code, we’re targeting the element that holds the parallax images, then selecting the background of the specific section we want to target based on its order on the page. In this example, we’re targeting the FIRST background image on the index page.

Add this code the Index Page Settings » Advanced » Code Injection


  <style>
  .Parallax-host-outer .Parallax-item:nth-of-type(1) {
    filter:blur(3px);
    transform:scale(1.1)
  }
  </style>

Table of Contents

Will Myers

I support web designers and developers in Squarespace by providing resources to improve their skills. 

https://www.will-myers.com
Previous
Previous

Adding CSS To A Squarespace Website

Next
Next

Sidebar Page Nav Plugin Demo