Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animated glowing border using CSS/ JS?

Tags:

javascript

css

Is it possible to use JS to automatically and continuously change a particular CSS property?

I want to create glowing border whose glow continuously brightens and dampens (using 3 properties to achieve this effect - border, box shadow, inset box shadow). How can I do so?

Please note that I am not talking about using "hover" or "active" states. Also I want it to work in all browsers, if possible.

like image 382
Debojyoti Ghosh Avatar asked Feb 21 '13 17:02

Debojyoti Ghosh


People also ask

How do you add a glowing border in CSS?

In this tutorial, you'll find some methods of creating a glowing border around an input field with CSS properties. In the example below, we add the :focus pseudo-class to the <input> element and then, specify the border-color and box-shadow properties. Also, we set the outline property to “none”.

Can you animate border in CSS?

CSS border animation is useful for giving a border image or container element a unique style. To make a website's user interface (UI) more attractive, use a CSS border animation design. CSS border animation is useful for giving a border image or container element a unique style.


1 Answers

Manipulating the above answer for CSS only solution

@-webkit-keyframes glow {
    to {
         border-color: #69c800;
    -webkit-box-shadow: 0 0 5px #69c800;
       -moz-box-shadow: 0 0 5px #69c800;
            box-shadow: 0 0 5px #69c800;
    }
}

.myGlower {
    background-color: #ccc;
    border: 1px solid transparent;
    -webkit-animation: glow 1.0s infinite alternate;  
     -webkit-transition: border 1.0s linear, box-shadow 1.0s linear;
       -moz-transition: border 1.0s linear, box-shadow 1.0s linear;
            transition: border 1.0s linear, box-shadow 1.0s linear;
    width: 100px;
    height: 100px;
    margin: 50px;
}
like image 65
hariszaman Avatar answered Sep 21 '22 13:09

hariszaman