Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

inset box-shadow for inputfield

Tags:

css

Can an inset box-shadow work on an inputfield?

JsFiddle: http://jsfiddle.net/hKTq2/

like image 346
user1026090 Avatar asked Aug 27 '12 11:08

user1026090


People also ask

Can I use box shadow inset?

To use box-shadow in Internet Explorer 9 or later, you must set border-collapse to separate . inset must be the last keyword in the declaration.

What does inset do in box shadow?

The presence of the inset keyword changes the shadow to one inside the frame (as if the content was debossed inside the box). Inset shadows are drawn inside the border (even transparent ones), above the background, but below content.

Can you have an inset and an outset box shadow?

Bookmark this question. Show activity on this post. The box-shadow property has a property value called inset , so the shadow can be inset, or outset.


2 Answers

Yes, this is something I was working on the other day, it is indeed possible.

input
{
  box-shadow:inset 0 0 5px 5px #888;
  background: #fff;
}

You just need to have a background set for the shadow to fall onto :)

http://jsfiddle.net/Kyle_/ZCq6w/

like image 51
Kyle Avatar answered Sep 19 '22 07:09

Kyle


In the meantime, this has become a common, though here's my "the perfect inset input".

input {
  background: #fff;
  color: #525865;
  border-radius: 4px;
  border: 1px solid #d1d1d1;
  box-shadow: inset 1px 2px 8px rgba(0, 0, 0, 0.07);
  font-family: inherit;
  font-size: 1em;
  line-height: 1.45;
  outline: none;
  padding: 0.6em 1.45em 0.7em;
  -webkit-transition: .18s ease-out;
  -moz-transition: .18s ease-out;
  -o-transition: .18s ease-out;
  transition: .18s ease-out;
}
input:hover {
  box-shadow: inset 1px 2px 8px rgba(0, 0, 0, 0.02);
}
input:focus {
  color: #4b515d;
  border: 1px solid #B8B6B6;
  box-shadow: inset 1px 2px 4px rgba(0, 0, 0, 0.01), 0px 0px 8px rgba(0, 0, 0, 0.2);
}
body {
  background: #fff;
  margin: 20px;
}
<input type="text" />
like image 26
dariodev Avatar answered Sep 19 '22 07:09

dariodev