用html实现7种自动颜色变换,使用CSS3 box-shadow实现的7个按钮悬停动画特效

CSS

语言:

CSSSCSS

确定

/*

https://developer.mozilla.org/en/docs/Web/CSS/box-shadow

box-shadow: [inset?] [top] [left] [blur] [size] [color];

Tips:

- We're setting all the blurs to 0 since we want a solid fill.

- Add the inset keyword so the box-shadow is on the inside of the element

- Animating the inset shadow on hover looks like the element is filling in from whatever side you specify ([top] and [left] accept negative values to become [bottom] and [right])

- Multiple shadows can be stacked

- If you're animating multiple shadows, be sure to keep the same number of shadows so the animation is smooth. Otherwise, you'll get something choppy.

*/

.fill:hover,

.fill:focus {

box-shadow: inset 0 0 0 2em var(--hover);

}

.pulse:hover,

.pulse:focus {

-webkit-animation: pulse 1s;

animation: pulse 1s;

box-shadow: 0 0 0 2em rgba(255, 255, 255, 0);

}

@-webkit-keyframes pulse {

0% {

box-shadow: 0 0 0 0 var(--hover);

}

}

@keyframes pulse {

0% {

box-shadow: 0 0 0 0 var(--hover);

}

}

.close:hover,

.close:focus {

box-shadow: inset -3.5em 0 0 0 var(--hover), inset 3.5em 0 0 0 var(--hover);

}

.raise:hover,

.raise:focus {

box-shadow: 0 0.5em 0.5em -0.4em var(--hover);

-webkit-transform: translateY(-0.25em);

transform: translateY(-0.25em);

}

.up:hover,

.up:focus {

box-shadow: inset 0 -3.25em 0 0 var(--hover);

}

.slide:hover,

.slide:focus {

box-shadow: inset 6.5em 0 0 0 var(--hover);

}

.offset {

box-shadow: 0.3em 0.3em 0 0 var(--color), inset 0.3em 0.3em 0 0 var(--color);

}

.offset:hover,

.offset:focus {

box-shadow: 0 0 0 0 var(--hover), inset 6em 3.5em 0 0 var(--hover);

}

.fill {

--color: #a972cb;

--hover: #cb72aa;

}

.pulse {

--color: #ef6eae;

--hover: #ef8f6e;

}

.close {

--color: #ff7f82;

--hover: #ffdc7f;

}

.raise {

--color: #ffa260;

--hover: #e5ff60;

}

.up {

--color: #e4cb58;

--hover: #94e458;

}

.slide {

--color: #8fc866;

--hover: #66c887;

}

.offset {

--color: #19bc8b;

--hover: #1973bc;

}

button {

color: var(--color);

-webkit-transition: 0.25s;

transition: 0.25s;

}

button:hover,

button:focus {

border-color: var(--hover);

color: #fff;

}

body {

color: #fff;

background: #17181c;

font: 300 1em 'Fira Sans', sans-serif;

-webkit-box-pack: center;

-ms-flex-pack: center;

justify-content: center;

-ms-flex-line-pack: center;

align-content: center;

-webkit-box-align: center;

-ms-flex-align: center;

align-items: center;

text-align: center;

min-height: 100vh;

display: -webkit-box;

display: -ms-flexbox;

display: flex;

}

button {

background: none;

border: 2px solid;

font: inherit;

line-height: 1;

margin: 0.5em;

padding: 1em 2em;

}

h1 {

font-weight: 400;

}

code {

color: #e4cb58;

font: inherit;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值