In this third installment of our CSS3 Series, we are diving right into several elements that are sure to make any website stand out from the crowd: Borders, shadows, and gradients. If you have been following along with our series, you’ve learned about transitions and infinite scrolling, both techniques that can give your website visitors a smooth and engaging user experience.
Borders
In order to get the achieved borders or rounded corners in the pre-CSS3 era, designers had to turn to Photoshop and use images to create this style. By using CSS3, designers are now able to render rounded corners, styled borders, and multiple borders faster than ever. Each corner can be styled independently using the individual border-radius property (border-bottom-left-radius, border-top-left-radius, etc.) or by creating a unified border style and using just the border-radius property. Below are a few simple examples to achieve different border styles. Keep note, for the best possible browser support, you should always include the vendor prefix (-webkit- and -moz-:).
A
|
B
|
C
|
D
|
Gradients
This feature allows us to apply multiple color declarations to one element without the use of images. Using gradients can add depth to backgrounds and complement navigation and buttons, while being flexible, scalable, and fast to implement. There are two primary methods: radial and linear. This effect is achieved by using the background-image property. The example below shows both the linear and radial methods.
Linear
Radial
Box shadows
The box-shadow property allows you to easily add a shadow to any element. This can help create priority within your content or call out specific areas on your website. As with many of these techniques, this was a challenge prior to CSS3 and required the use of images to achieve.
A
|
B
|
C
|
Additional resources
Border Radius GeneratorTools for testing various border radii.
CSS3 Tricks – Gradients
Overview of how to use gradients.
The Ultimate Gradient Editor
Gradient generator with vendor prefixes, sass output and much more.
Need help implementing these techniques and tips on your website? TBH is a creative agency that focuses on website design and development. Let us help you with your next website project.
Let’s start talking