Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a div glow with jquery

I wonder how to make a div glow in a specific color when the page has loaded.

<div id="glow" class="logo registrer"><a href="http://henricson.net/registrer.php" class="understrek">Registrer deg</a></div>

This is the div i want to glow. Thank you :)

like image 293
herre.mann Avatar asked Mar 17 '13 11:03

herre.mann


2 Answers

CSS3 can do that:

-webkit-box-shadow:0 0 20px blue; 
-moz-box-shadow: 0 0 20px blue;
box-shadow:0 0 20px blue;

Here's a JSFiddle that shows that it does, in fact, it works fine with me, check it out to see :)

like image 176
Suits999 Avatar answered Sep 19 '22 11:09

Suits999


I'm not sure how you mean to glow? If to simply change colour then you can do something like the below.

$(document).ready(function(){
   $('#glow').animate({backgroundColor:'green'});
});

You could then add some box-shadow to add a glow effect.

-webkit-box-shadow: 0px 0px 5px 5px rgba(0, 150, 0, 0.3);
box-shadow: 0px 0px 5px 5px rgba(0, 150, 0, 0.3);

Please see this example fiddle of an animating background colour and shadow added.

EDIT

Sorry I forgot to mention you'll need to include the color animation plugin to be able to do this.

Also here is another fiddle that runs after half a second and then removes the glow.... obviously this would need alot of tweaking to make it look nice.

like image 42
dev Avatar answered Sep 20 '22 11:09

dev