Blurry Effect: CSS Tutorial (Day 29 of CSS3 in 30 Days)

freeCodeCamp.org · Beginner ·🛠️ AI Tools & Apps ·7y ago
Skills: HTML & CSS80%

Key Takeaways

Creates a blurred depth of field effect with CSS3

Full Transcript

hey everybody welcome back to css3 in 30 days today's day number 29 and we're going to just do something a little simple we're going to be creating a blurry depth of field blur your images unblur your images effect whatever we want to call it essentially you can make images and elements blurry and transition in and out of that blurred effect to whatever degree that you wish with just css3 now typically before you'd have to do this with photoshop or maybe even like a jquery plugin or something like that but we can do that in css3 and it's really cool now it's quite simple in its you know in its basic form but you can do a lot with it if you had layered elements and you wanted certain elements to be blurry in the background and certain ones be to be focused in the front like a legitimate depth of field effect where your your focus point is on a specific layer and then the other ones come in and out of focus you can play around with that but in this case i'm gonna show you just simply how the blur effect works and we're just gonna to blur and unblur and transition in and out of that with css3 so here we go day 29 the blurry effect so we just have four images here that are just standard stock images but down here what we're going to do is we're going to have them start out as blurry once we kind of hover in view and then when you focus on one it will kind of come forward and be it within focus with the other ones be being blurry in the background when we hover out of that it should go back to its blurred state and we can also hover to a different one it will switch and now that one is in focus this one is in focus this one is in focus a good uh practical example or practical use of this specific demo would be um perhaps portfolio images or a gallery of images now the blur effect here is quite dramatic now you don't have to have it be that dramatic of a blurred effect but maybe in some cases that might be what you want so let's jump into our code editor download day number 29 and then as you can see in our markup here uh we simply just have four images there's nothing crazy about this at all it's quite simple head to your sandbox and let's start coding so we're gonna select the depth gallery that is the div that wraps the four images and we're simply just going to position relative and then display inline block then we're going to select the depth gallery image so all the images we're gonna give them a border of solid let's do eight pixels or seven doesn't really matter white box shadow we're to go 0 0 5 pixels and then rgba 0 0 0 and then 0.3 and then we'll say cursor pointer because we're hovering over it we want that interaction you don't have to you can change it to crosshair let's do that that'd be fun and we're going to say transition we're going to transition the filter property because we're going to be using css3 filter property i'll show you in a moment here 0.3 seconds linear we're also going to transition the transform property at 0.3 seconds and linear as well save that now if you go to our browser you can see the images now have a nice little like a nice border a white a white border around it with a little bit of a shadow it's just a nice a nice way of displaying an image just makes it look nice gives it a frame now we're gonna go back here we're gonna say depth gallery hover when you hover over the entire depth gallery and then image so when you hover over that element the entire pyramint element parent element do something with the images and that's simply going to be filter so we can apply some graphical effects we're going to say blur and then 5 pixels so that's how you do that that's how you blur an image check it out so when i hover it in there so i'm out of the element itself when i hover into that element it's going to blur everything 5 pixels now you can have it be more exaggerated or less exaggerated by changing the value higher or lower this is one pixel very subtle and if i did 10 pixels you can't even recognize what the image is really so there we go i'm going to stick with let's say 4 pixels and i'm going to transform it and i'm going to use the scale value here and scale is simply just the size the scale of it don't want to be one would equal it's not going to do anything it's going to be its normal size 0.9 is 90 of its size both height and width you can have it be 2 and it'll be twice the size so you can scale an element any element using transform scale save it now when i hover into the depth gallery everything shrinks point nine and goes blurry to four pixel blur effect okay and the only thing we have to do now is when you hover over say depth gallery image and then hover over an individual image we're going to filter we're going to overwrite that filter property and blur to zero so just back to a standard in focus image transform scale and then 1.1 and because we're transitioning the images everything is got a nice kind of fluid transition in between so save it now let's check it out we hover it in everything goes down to 0.9 and goes blurry you hover over one comes up into focus and is a little bit larger when you hover out onto a different one one goes back one comes forward nice and simple so that's it for today's demo for the blurry effect we simply played around with filters the filter blur and the transform scale you could do everything from transforming and rotating upon that uh when you hover but because this was about blurring images we're simply using the filter blur effect i challenge you to take this a little bit further i showed you how to use the blur and transition in between in focus and everything like that but i challenge you to do something exciting with this maybe have the images individually be stacked in front of each other have them be cascading out in front of each other so you could see an image and then one in front and a little bit down another one in front and a little bit down and so on and so forth and when you hover over that image you know maybe pop it out of like a deck of cards and have it come in focus and the other ones go blurry or maybe you you have separate individual png transparent elements like a scene you have maybe three trees or something like that and when you hover over one tree that one's in focus you hover over this one it's in focus the other two are blurry almost like if you're a photographer and you're you're photographing someone and you want to put a certain element in focus and have you know the background be blurry and the foreground be blurry but this one single plane of focus that's kind of what you're doing here so i challenge you to experiment with this and don't just leave it here i've given you the tool and now i want you to play with it a bit so see what you can come up with and i will see you in tomorrow's final lesson day number 30. so i'll see you there and have fun with the blur effect cheers [Music]

Original Description

Create a blurred depth of field effect with CSS3! ⭐️Files you need ⭐️ 💻Blurry Effect Code: https://www.dropbox.com/sh/fsiac0oezw9wode/AAAazOlFVobJpNFCFBiB8g3Ia?dl=0 💻All tutorials in this series need this "_theme-styles" directory (only download once): https://www.dropbox.com/sh/890hx6ke34oovaz/AAByJ-jb-H5pWuIUx7t_GvQqa?dl=0 This video works as a stand-alone tutorial but is also day 29 of CSS3 in 30 Days. For the rest of the series, check out this playlist: https://www.youtube.com/playlist?list=PLWKjhJtqVAbl1AfjiGyYxwpdAPi5v-1OU CSS3 in 30 Days is developed by Brad Hussey. Check out his website for more great tutorials: https://codecollege.ca/ -- Learn to code for free and get a developer job: https://www.freecodecamp.org Read hundreds of articles on programming: https://medium.freecodecamp.org ❤️ Support for this channel comes from our friends at Scrimba – the coding platform that's reinvented interactive learning: https://scrimba.com/freecodecamp
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from freeCodeCamp.org · freeCodeCamp.org · 0 of 60

← Previous Next →
1 React: Production Server Setup Part 2 - Live Coding with Jesse
React: Production Server Setup Part 2 - Live Coding with Jesse
freeCodeCamp.org
2 cookies vs localStorage vs sessionStorage - Beau teaches JavaScript
cookies vs localStorage vs sessionStorage - Beau teaches JavaScript
freeCodeCamp.org
3 Browser history tutorial - Beau teaches JavaScript
Browser history tutorial - Beau teaches JavaScript
freeCodeCamp.org
4 Graph Data Structure Intro (inc. adjacency list, adjacency matrix, incidence matrix)
Graph Data Structure Intro (inc. adjacency list, adjacency matrix, incidence matrix)
freeCodeCamp.org
5 React: Parameterized Routing with Next.js - Live Coding with Jesse
React: Parameterized Routing with Next.js - Live Coding with Jesse
freeCodeCamp.org
6 React: Dealing with jQuery Issues - Live Coding with Jesse
React: Dealing with jQuery Issues - Live Coding with Jesse
freeCodeCamp.org
7 setInterval and setTimeout: timing events - Beau teaches JavaScript
setInterval and setTimeout: timing events - Beau teaches JavaScript
freeCodeCamp.org
8 Browser and Device Testing - Live Coding with Jesse
Browser and Device Testing - Live Coding with Jesse
freeCodeCamp.org
9 Last Minute Updates - Live Coding with Jesse
Last Minute Updates - Live Coding with Jesse
freeCodeCamp.org
10 Post Launch Updates - Live Coding with Jesse
Post Launch Updates - Live Coding with Jesse
freeCodeCamp.org
11 React: Setting Up Google Analytics - Live Coding with Jesse
React: Setting Up Google Analytics - Live Coding with Jesse
freeCodeCamp.org
12 React: Masonry Layout - Live Coding with Jesse
React: Masonry Layout - Live Coding with Jesse
freeCodeCamp.org
13 Load Balancing Digital Ocean Droplets - Live Coding with Jesse
Load Balancing Digital Ocean Droplets - Live Coding with Jesse
freeCodeCamp.org
14 try, catch, finally, throw - error handling in JavaScript
try, catch, finally, throw - error handling in JavaScript
freeCodeCamp.org
15 Load Balancing: SSL Passthrough Setup - Live Coding with Jesse
Load Balancing: SSL Passthrough Setup - Live Coding with Jesse
freeCodeCamp.org
16 Graphs: breadth-first search - Beau teaches JavaScript
Graphs: breadth-first search - Beau teaches JavaScript
freeCodeCamp.org
17 React: Masonry Layout Part 2 - Live Coding with Jesse
React: Masonry Layout Part 2 - Live Coding with Jesse
freeCodeCamp.org
18 React: WordPress API Live Search - Live Coding with Jesse
React: WordPress API Live Search - Live Coding with Jesse
freeCodeCamp.org
19 Creating WordPress Custom Post Types - Live Coding With Jesse
Creating WordPress Custom Post Types - Live Coding With Jesse
freeCodeCamp.org
20 Dates - Beau teaches JavaScript
Dates - Beau teaches JavaScript
freeCodeCamp.org
21 Miscellaneous Front End Updates - Live Coding with Jesse
Miscellaneous Front End Updates - Live Coding with Jesse
freeCodeCamp.org
22 Merging a Pull Request from GitHub - Live Coding with Jesse
Merging a Pull Request from GitHub - Live Coding with Jesse
freeCodeCamp.org
23 React + Prettier + Standard JS - Live Coding with Jesse
React + Prettier + Standard JS - Live Coding with Jesse
freeCodeCamp.org
24 React: Sortable Responsive Table - Live Coding with Jesse
React: Sortable Responsive Table - Live Coding with Jesse
freeCodeCamp.org
25 Geolocation Sorting by Distance - Live Coding with Jesse
Geolocation Sorting by Distance - Live Coding with Jesse
freeCodeCamp.org
26 Tradeoff Matrix - Agile Software Development
Tradeoff Matrix - Agile Software Development
freeCodeCamp.org
27 The Definition of Ready - Agile Software Development
The Definition of Ready - Agile Software Development
freeCodeCamp.org
28 Getting first React job without experience - Ask Preethi
Getting first React job without experience - Ask Preethi
freeCodeCamp.org
29 React: Google Analytics Click Tracking - Live Coding with Jesse
React: Google Analytics Click Tracking - Live Coding with Jesse
freeCodeCamp.org
30 Submitting a PR to an Open Source Project - Live Coding with Jesse
Submitting a PR to an Open Source Project - Live Coding with Jesse
freeCodeCamp.org
31 Should I go back to school to get CS degree? - Ask Preethi
Should I go back to school to get CS degree? - Ask Preethi
freeCodeCamp.org
32 Hero Section CSS Changes - Live Coding with Jesse
Hero Section CSS Changes - Live Coding with Jesse
freeCodeCamp.org
33 Working Agreement - Agile Software Development
Working Agreement - Agile Software Development
freeCodeCamp.org
34 A day at Pennybox with Co-Founder Reji Eapen
A day at Pennybox with Co-Founder Reji Eapen
freeCodeCamp.org
35 React: Sorting and Filtering Data - Live Coding with Jesse
React: Sorting and Filtering Data - Live Coding with Jesse
freeCodeCamp.org
36 React: Sorting and Filtering Data Part 2 - Live Coding with Jesse
React: Sorting and Filtering Data Part 2 - Live Coding with Jesse
freeCodeCamp.org
37 React: Building a New UI - Live Coding with Jesse
React: Building a New UI - Live Coding with Jesse
freeCodeCamp.org
38 Definition of Done - Agile Software Development
Definition of Done - Agile Software Development
freeCodeCamp.org
39 Getting started with jQuery (tutorial) - Beau teaches JavaScript
Getting started with jQuery (tutorial) - Beau teaches JavaScript
freeCodeCamp.org
40 Making a React Blog with WordPress Content - Live Coding with Jesse
Making a React Blog with WordPress Content - Live Coding with Jesse
freeCodeCamp.org
41 React, NextJS, CSS - Live Coding with Jesse
React, NextJS, CSS - Live Coding with Jesse
freeCodeCamp.org
42 jQuery events - Beau teaches JavaScript
jQuery events - Beau teaches JavaScript
freeCodeCamp.org
43 React/NextJS Routing and WordPress API Custom Types - Live Coding with Jesse
React/NextJS Routing and WordPress API Custom Types - Live Coding with Jesse
freeCodeCamp.org
44 React: Working with API Data - Live Coding with Jesse
React: Working with API Data - Live Coding with Jesse
freeCodeCamp.org
45 React: Refactoring Components - Live Streaming with Jesse
React: Refactoring Components - Live Streaming with Jesse
freeCodeCamp.org
46 jQuery effects - Beau teaches JavaScript
jQuery effects - Beau teaches JavaScript
freeCodeCamp.org
47 More React Refactoring - Live Coding with Jesse
More React Refactoring - Live Coding with Jesse
freeCodeCamp.org
48 animate in jQuery - Beau teaches JavaScript
animate in jQuery - Beau teaches JavaScript
freeCodeCamp.org
49 "Finishing" My React Site - Live Coding with Jesse
"Finishing" My React Site - Live Coding with Jesse
freeCodeCamp.org
50 Starting a New React Project (P2D1) - Live Coding with Jesse
Starting a New React Project (P2D1) - Live Coding with Jesse
freeCodeCamp.org
51 React Project 2 Day 2: Learning Material UI - Live Coding with Jesse
React Project 2 Day 2: Learning Material UI - Live Coding with Jesse
freeCodeCamp.org
52 The Agile Manifesto - Agile Software Development
The Agile Manifesto - Agile Software Development
freeCodeCamp.org
53 jQuery: get and set with http, text, val, and attr - Beau teaches JavaScript
jQuery: get and set with http, text, val, and attr - Beau teaches JavaScript
freeCodeCamp.org
54 React Project 2 Day 3 - Live Coding with Jesse
React Project 2 Day 3 - Live Coding with Jesse
freeCodeCamp.org
55 The INVEST approach to product backlog items
The INVEST approach to product backlog items
freeCodeCamp.org
56 React Project 2 Day 4 - Live Coding with Jesse
React Project 2 Day 4 - Live Coding with Jesse
freeCodeCamp.org
57 Chickens and Pigs - Agile Software Development
Chickens and Pigs - Agile Software Development
freeCodeCamp.org
58 React Project 2 Day 5 - Live Coding with Jesse
React Project 2 Day 5 - Live Coding with Jesse
freeCodeCamp.org
59 jQuery: add and remove DOM elements - Beau teaches JavaScript
jQuery: add and remove DOM elements - Beau teaches JavaScript
freeCodeCamp.org
60 React Project 2 Day 6 - Live Coding with Jesse
React Project 2 Day 6 - Live Coding with Jesse
freeCodeCamp.org

Related Reads

Up next
monday.com Automation: Fix Missing Emails in Seconds
Mastering monday
Watch →