Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: Box-Shadow Transition Multiple Shadows

Tags:

html

css

So I have a button with initial shadow set. I want to transition the shadow on hover into another value of shadow.

button {
  height:100px;
  width:200px;
  padding:10px;
  margin:5px;
  border:none;
  border-radius:10px;
  box-shadow: 10px 10px 20px #dde4ef, -10px -10px 20px white;
  transition: box-shadow 0.5s ease-in;
}

button:hover{
  box-shadow: inset 10px 10px 20px #dde4ef, inset -10px -10px 20px white;
}
<button>This Button</button>

Its not working

like image 461
Alvin Stefanus Avatar asked Jun 23 '26 17:06

Alvin Stefanus


1 Answers

Prepare your inset shadows by using inset 0 0 0 transparent, inset 0 0 0 transparent,

button {
  height:100px;
  width:200px;
  padding:10px;
  margin:5px;
  border:none;
  border-radius:10px;
  display: inline-block;
  box-shadow:
     inset 0 0 0 transparent, inset 0 0 0 transparent, /* Prepared inset shadows */
     10px 10px 20px #dde4ef, -10px -10px 20px white;   /* Outer shadows */
  transition: box-shadow 0.5s ease-in;
}

button:hover{
  box-shadow: inset 10px 10px 20px #dde4ef, inset -10px -10px 20px white;
}
<button type="button">HOVER ME</button>
like image 188
Roko C. Buljan Avatar answered Jun 25 '26 11:06

Roko C. Buljan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!