Add a Colour Gradient to Buttons
What does this code do?
This code snippet will allow you to add a colour gradient to buttons.
Create your CSS Gradient
First, decide on how you would like your gradient to look. Go to https://mycolor.space/gradient and design the gradient code you would like.
Save the code generated from the word “linear” to the “ ; “ . In the example above, I would save the code outlined in red.
linear-gradient(93deg, rgba(2,0,36,1) 13%, rgba(3,1,43,1) 15%, rgba(9,9,121,1) 43%, rgba(0,212,255,1) 78%);
Code Snippets
Copy and paste the following code into Design > Custom CSS.
SELECTOR .sqs-block-button a { background: CODE GOES HERE; }
Then change the word SELECTOR to one of the selectors below.
Squarespace 7.0
/* One Page */ #COLLECTIONID /* The Whole Footer */ footer /* The Top Footer Section */ .Footer-blocks--top /* The Middle Footer Section */ .Footer-blocks--middle /* The Bottom Footer Section */ .Footer-blocks--bottom /* One Section */ #PAGEID /* One Button Block */ #BLOCKID
Squarespace 7.1
/* One Page */ #COLLECTIONID /* The Whole Footer */ #footer-sections /* One Section */ #COLLECTIONID #page .page-section:nth-of-type(1) /* One Button Block */ #BLOCKID
Then replace CODE GOES HERE with the code you saved from the Color Gradient Generator. For example, your code will look something like…
SELECTOR .sqs-block-button a { background: linear-gradient(93deg, rgba(2, 0, 36, 1) 13%, rgba(3, 1, 43, 1) 15%, rgba(9, 9, 121, 1) 43%, rgba(0, 212, 255, 1) 78%); }
How To Use It
Use https://mycolor.space/gradient to create the colour gradient you would like. Save the code from “linear” to the “ ; “
Copy and paste the code snippet as indicated above.
Choose the selector that matches your situation.
To learn how to find a collection id, page id, or block id check out our Start Here guide.
If targeting one section in Squarespace 7.1, change the 1 to match the section you are trying to change.
Note that we have the -webkit- in front of the word linear to help support your gradient across multiple browsers.