Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

glow around div with border and color

Tags:

html

css

Is there any way to add a glow around the div? Look at twitter login and how there is a blue glow around the input box, can that be done for the div?

like image 914
DemCodeLines Avatar asked Mar 17 '12 18:03

DemCodeLines


People also ask

How do you make a glow border?

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”.


4 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;

Working JSFiddle.

like image 69
Elliot Bonneville Avatar answered Oct 06 '22 06:10

Elliot Bonneville


Here is the complete code to style a div exactly like the twitter login input. The styles for the blue border are the box-shadow and border styles for the selector div[contenteditable]:focus. Live demo here (click).

Markup:

<div contenteditable="true">Username or email</div>

CSS:

div[contenteditable]:focus {
  border: 1px solid rgb(86, 180, 239);
  box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.05) inset, 0px 0px 8px rgba(82, 168, 236, 0.6);
}

div[contenteditable] {
  width: 97%;
  max-width: 280px;
  margin-right: 10px;

  font-family: Arial,sans-serif;

  -webkit-box-shadow: inset 0 1px 3px rgba(0,0,0,.05),0 1px 0 rgba(255,255,255,.075);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.05),0 1px 0 rgba(255,255,255,.075);

  display: inline-block;
  padding: 4px;
  margin: 0;
  outline: 0;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 3px;

  font-size: 13px;
  line-height: 20px;
}
like image 41
m59 Avatar answered Oct 06 '22 05:10

m59


As shown before, use css: focus, border and box-shadow.

If using IE, make sure <doctype> is specified.

.text:focus {
    border: 1px solid #07c;
    box-shadow: 0 0 10px #07c;
}

jsFiddle example.

like image 23
Samwise Avatar answered Oct 06 '22 05:10

Samwise


Also you will face some problem with Internet Explorer while dealing this issue. IE-9 How ever supports box-shadow but the previous versions don't, Check it out here for making it work in all versions of IE

like image 35
pshirishreddy Avatar answered Oct 06 '22 04:10

pshirishreddy