Estimated reading time: 2 minutes, 45 seconds

CSS3 Glow for inputs (like on twitter)

Textarea animated glow image

Hey all,

Add a glow to your web design

Lot’s of you may have seen on twitter the new “glow effect” they have added recently. It adds a very nice touch and looks really cool on their website I think. It also adds an extra level of user accessibility as you know when you have selected much quicker.This tutorial is very easy to implement and can look great on your website. It can also be easily added to your current website design.

Right lets get to it… So what do we need? Well first of all all you need to do is have your textarea’s set up in your html… like so:

<textarea name="text" id="">Your pre-filled content.....</textarea>

Easy… Let’s assume you know how to attach you’re css file in your html head. And now we need to use standard css2 methods to stylize the textarea. This is all personal preference but I am going to use one I think looks quite cool! Here is my css I am going to use…

textarea#styleid{
color:#666;
font-size:14px;
-moz-border-radius: 8px; -webkit-border-radius: 8px;
margin:5px 0px 10px 0px;
padding:10px;
height:75px;
width:350px;
border:#999 1px solid;
font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
}

textarea#styleid:focus{
color:#000;
outline:none;
border:#35a5e5 1px solid;
}

So now we have something that will look pretty good…

it’s all down to personal preference though…. Our next step is to Add the glow

To add the glow we need to implement the new CSS3 lines which utilizes the moz-webkit webkit and safari’s webkit. This is the cool bit. Now bare in mind we are using RGBA (A stands for alpha i.e. transparency) This is so we can control the opacity on states which we need to overcome an animation issue.

box-shadow: 0 0 5px rgba(81, 203, 238, 0);
-webkit-box-shadow: 0 0 5px rgba(81, 203, 238, 0);
-moz-box-shadow: 0 0 5px rgba(81, 203, 238, 0);

We also need to disable the nasty auto outlining of the textarea that the browser does by default.

Add this into the css: outline:none;

Now we get…..

Hokay!… Now let’s add the animation using CSS3′s new animation/transition – which might I add is VERRYY cool. We need to add the transition code to the main styling level of the style id (in other words don’t put it on the focus state like #divid:focus only on the main one #divid…okay?)

transition: all 0.25s ease-in-out;
-webkit-transition: all 0.25s ease-in-out;
-moz-transition: all 0.25s ease-in-out;

As you can see it’s easy to understand and change… so for example 0.25s can be changed to 0.5s to slow it down and there is various other methods of transitions – to come in later post?
Right ok so now we have our glow css in-place the on-focus and off-focus using transparency (RGBA) and now we’ve added our transition code…

So the full thing is now like this in the css:


textarea#styleid{
color:#666;
font-size:14px;
-moz-border-radius: 8px; -webkit-border-radius: 8px;
margin:5px 0px 10px 0px;
padding:10px;
height:75px;
width:350px;
border:#999 1px solid;
font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
transition: all 0.25s ease-in-out;
-webkit-transition: all 0.25s ease-in-out;
-moz-transition: all 0.25s ease-in-out;
box-shadow: 0 0 5px rgba(81, 203, 238, 0);
-webkit-box-shadow: 0 0 5px rgba(81, 203, 238, 0);
-moz-box-shadow: 0 0 5px rgba(81, 203, 238, 0);
}


textarea#styleid:focus{
color:#000;
outline:none;
border:#35a5e5 1px solid;
font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
box-shadow: 0 0 5px rgba(81, 203, 238, 1);
-webkit-box-shadow: 0 0 5px rgba(81, 203, 238, 1);
-moz-box-shadow: 0 0 5px rgba(81, 203, 238, 1);
}

And finally we have this effect:

css3 glow animation image

As can be found around the web on bigger sites like yebutno.com

Working example:

Posted in Tips & Tricks | Tags: , , | 12 Comments
By Stefan |

12 Comments

  • Please also check out my site: Glasgow Web Design Thanks

    Posted May 19, 2010 at 11:16 pm | Permalink
  • Geoff

    Thanks for u r information

    its very useful

    Posted July 28, 2010 at 12:20 pm | Permalink
  • Joaquin

    I’ve tested it on Opera 10.61 (latest) and the round corners doesn’t seems to work.

    I guess you could add the “official” border-radius: 8px;

    Good post!

    Posted September 3, 2010 at 12:37 am | Permalink
  • Yes sorry I forgot to add in border-radius! And thank you

    Posted September 3, 2010 at 1:24 am | Permalink
  • Hawk

    Why is the resizing on the final textarea so slow? I am guessing it’s Javascript-controlled, instead of by the native textbox resizing functionality. Am I right?

    (I’m on Safari 5 (Mac).)

    Posted November 20, 2010 at 7:47 pm | Permalink
  • It’s due to the CSS3 transition paramteres that makes the actual glow fade in (transits) as well :)

    Posted December 1, 2010 at 5:12 pm | Permalink
  • nikeee

    thank you very much admin im going to use this on my site :)

    Posted March 27, 2011 at 6:21 pm | Permalink
  • nice post
    and thank’s for it

    Posted July 18, 2011 at 5:49 am | Permalink
  • Webgenius

    Main this geeks me out! Way nice.

    Posted July 19, 2011 at 4:05 pm | Permalink
  • wow… thats great… thanx so much… this is what im looking for.. ^^

    Posted July 21, 2011 at 9:21 pm | Permalink
  • Admin, I already add thats code on my blog post and its work, but its only glowing by 1px… I add code above tag </head>
    is there something that I miss??

    Posted July 21, 2011 at 11:36 pm | Permalink
  • Malte

    Thanks!

    Posted September 2, 2011 at 11:14 am | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe
Keep up to date with our latest posts.

Learn more about making the most of your website, marketing and seo. It takes two seconds to subscribe to our rss feed.
Contact
You can get in contact with us via phone or e-mail, we will get back to you very promptly.

0141 416 2221
Call you back?
If you would like us to call you back, just pop your number in below and we will get back to you very soon!

Copyright © 2005 - 2012 Pretty Klicks (prettyklicks.com)