Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Tutorials
CSS3 - Creating a Basic "blur" effect.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Sysode" data-source="post: 320542" data-attributes="member: 25453"><p>Just something small to post. It was something I was playing around with the other day, intentionally for a NSFW filter (don't ask) however I never got around to finishing it. </p><p></p><p>Nevertheless, I thought I'd share how to create a basic CSS blur effect. This example will be on hover.. For the full demo and code, <a href="http://codepen.io/Sysode/pen/LEbxLe" target="_blank">visit my Codepen</a>.</p><p></p><p style="text-align: center"><strong><u><span style="font-size: 18px">Creating a blur using <em>filter</em></span></u></strong></p><p>It's a lot easier than it seems. We shall be creating a blurred image by applying the following CSS to our image attribute (or class).</p><p>[CODE]img {</p><p> -webkit-filter: blur(20px);</p><p> -moz-filter: blur(20px);</p><p> filter:blur(20px);</p><p> transition: 1s ease-out;</p><p>}[/CODE]</p><p>For this example I have just used the img tag in HTML and applied the pure basic CSS. Notice how, in brackets, is the blur amount. I have applied 20px as it almost makes the images impossible to work out. Notice have I have also applied a transition? That will be for later when it comes to animation on hover. </p><p></p><p>For my HTML I have created a class (which will be used later) and the child element inside of that is my img tag. As seen below:</p><p>[HTML]<div class="image" id="nsfw"></p><p> <img src="http://lorempixel.com/output/sports-q-c-640-480-5.jpg" alt="some image"></p><p></div>[/HTML]</p><p></p><p>Now for some animation.. This is just to make it a little fancy upon hover (all using pure CSS). For that I have used the code below:</p><p>[CODE].image:hover img,</p><p>.image:hover ~ img {</p><p> -webkit-filter: blur(0);</p><p>}[/CODE]</p><p></p><p>For this we use the :hover effect for both the img and we also use the general sibling selector (for some reason it fails work without it) but this basically selects any child element of the class .image, directly the img tag. </p><p></p><p><strong>That's not all...</strong> There are also plenty of other filters that can be used. A list can be seen below:</p><ul> <li data-xf-list-type="ul">blur()</li> <li data-xf-list-type="ul">brightness()</li> <li data-xf-list-type="ul">contrast()</li> <li data-xf-list-type="ul">url()</li> <li data-xf-list-type="ul">drop-shadow()</li> <li data-xf-list-type="ul">grayscale()</li> <li data-xf-list-type="ul">hue-rotate()</li> <li data-xf-list-type="ul">invert()</li> <li data-xf-list-type="ul">opacity()</li> <li data-xf-list-type="ul">sepia()</li> </ul><p>Eh, this was just a post because I think some pretty cool things can be done with these effects - they aren't that new at all.. Just haven't seen it posted around here before so I thought I'd share. Let us know how you get on below!</p></blockquote><p></p>
[QUOTE="Sysode, post: 320542, member: 25453"] Just something small to post. It was something I was playing around with the other day, intentionally for a NSFW filter (don't ask) however I never got around to finishing it. Nevertheless, I thought I'd share how to create a basic CSS blur effect. This example will be on hover.. For the full demo and code, [URL='http://codepen.io/Sysode/pen/LEbxLe']visit my Codepen[/URL]. [CENTER][B][U][SIZE=5]Creating a blur using [I]filter[/I][/SIZE][/U][/B][/CENTER] It's a lot easier than it seems. We shall be creating a blurred image by applying the following CSS to our image attribute (or class). [CODE]img { -webkit-filter: blur(20px); -moz-filter: blur(20px); filter:blur(20px); transition: 1s ease-out; }[/CODE] For this example I have just used the img tag in HTML and applied the pure basic CSS. Notice how, in brackets, is the blur amount. I have applied 20px as it almost makes the images impossible to work out. Notice have I have also applied a transition? That will be for later when it comes to animation on hover. For my HTML I have created a class (which will be used later) and the child element inside of that is my img tag. As seen below: [HTML]<div class="image" id="nsfw"> <img src="http://lorempixel.com/output/sports-q-c-640-480-5.jpg" alt="some image"> </div>[/HTML] Now for some animation.. This is just to make it a little fancy upon hover (all using pure CSS). For that I have used the code below: [CODE].image:hover img, .image:hover ~ img { -webkit-filter: blur(0); }[/CODE] For this we use the :hover effect for both the img and we also use the general sibling selector (for some reason it fails work without it) but this basically selects any child element of the class .image, directly the img tag. [B]That's not all...[/B] There are also plenty of other filters that can be used. A list can be seen below: [LIST] [*]blur() [*]brightness() [*]contrast() [*]url() [*]drop-shadow() [*]grayscale() [*]hue-rotate() [*]invert() [*]opacity() [*]sepia() [/LIST] Eh, this was just a post because I think some pretty cool things can be done with these effects - they aren't that new at all.. Just haven't seen it posted around here before so I thought I'd share. Let us know how you get on below! [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Tutorials
CSS3 - Creating a Basic "blur" effect.
Top