CSS3白色质感3D按钮特效源码

这是一款css3白色质感3D按钮特效。该按钮使用svg做为图标,通过css3代码,打造出非常炫酷的3d按钮效果。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Mf75Yw1c-1589804801000)(https://upload-images.jianshu.io/upload_images/20062408-ea7c84bb1bd0ef90.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]

使用方法

HTML结构

Not focusable

CSS样式


{
  from {
    box-shadow: 0 4px 3px 1px #FCFCFC, 0 6px 8px #D6D7D9, 0 -4px 4px #CECFD1, 0 -6px 4px #FEFEFE, inset 0 0 10px 0px rgba(0, 0, 250, 0.6);
  }
  to {
    box-shadow: 0 4px 3px 1px #FCFCFC, 0 6px 8px #D6D7D9, 0 -4px 4px #CECFD1, 0 -6px 4px #FEFEFE, inset 0 0 3px 3px #CECFD1;
  }
}
@keyframes active {
  from {
    box-shadow: 0 4px 3px 1px #FCFCFC, 0 6px 8px #D6D7D9, 0 -4px 4px #CECFD1, 0 -6px 4px #FEFEFE, inset 0 0 10px 0px rgba(0, 0, 250, 0.6);
  }
  to {
    box-shadow: 0 4px 3px 1px #FCFCFC, 0 6px 8px #D6D7D9, 0 -4px 4px #CECFD1, 0 -6px 4px #FEFEFE, inset 0 0 3px 3px #CECFD1;
  }
}
*,
*:before,
*:after {
  box-sizing: border-box;
}
 
body {
  margin: 0;
  padding: 30px;
  background: #f8f8f8;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
 
.grid {
  max-width: 400px;
  margin: 50px auto;
  display: grid;
  grid-template-columns: 150px 150px 50px;
  align-items: center;
  justify-content: center;
  grid-gap: 40px 25px;
}
 
button,
[role="button"] {
  -webkit-appearance: none;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  cursor: pointer;
  width: 150px;
  height: 50px;
  background-image: linear-gradient(to top, #D8D9DB 0%, #fff 80%, #FDFDFD 100%);
  border-radius: 30px;
  border: 1px solid #8F9092;
  box-shadow: 0 4px 3px 1px #FCFCFC, 0 6px 8px #D6D7D9, 0 -4px 4px #CECFD1, 0 -6px 4px #FEFEFE, inset 0 0 3px 0 #CECFD1;
  transition: all 0.2s ease;
  font-family: "Source Sans Pro", sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #606060;
  text-shadow: 0 1px #fff;
}
button::-moz-focus-inner,
[role="button"]::-moz-focus-inner {
  border: 0;
}
button > *,
[role="button"] > * {
  transition: -webkit-transform 0.2s ease;
  transition: transform 0.2s ease;
  transition: transform 0.2s ease, -webkit-transform 0.2s ease;
}
button:hover:not([disabled]),
[role="button"]:hover:not([disabled]) {
  box-shadow: 0 4px 3px 1px #FCFCFC, 0 6px 8px #D6D7D9, 0 -4px 4px #CECFD1, 0 -6px 4px #FEFEFE, inset 0 0 3px 3px #CECFD1;
}
button:hover:not([disabled]) > *,
[role="button"]:hover:not([disabled]) > * {
  -webkit-transform: scale(0.975);
          transform: scale(0.975);
}
button:focus:not(:active),
[role="button"]:focus:not(:active) {
  -webkit-animation: active 0.9s alternate infinite;
          animation: active 0.9s alternate infinite;
  outline: none;
}
button:active:not([disabled]),
[role="button"]:active:not([disabled]) {
  box-shadow: 0 4px 3px 1px #FCFCFC, 0 6px 8px #D6D7D9, 0 -4px 4px #CECFD1, 0 -6px 4px #FEFEFE, inset 0 0 5px 3px #999, inset 0 0 30px #aaa;
}
button:active:not([disabled]) > *,
[role="button"]:active:not([disabled]) > * {
  -webkit-transform: scale(0.95);
          transform: scale(0.95);
}
button:disabled,
[role="button"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
button.icon,
[role="button"].icon {
  width: 50px;
}
button.icon svg,
[role="button"].icon svg {
  margin-top: 3px;
  width: 30px;
  height: 30px;
}

从事全栈6年,专门建立的学习Q-q-u-n ⑦⑧④-⑦⑧③-零①② 分享学习方法和需要注意的小细节,互相交流学习,不停更新最新的教程和学习技巧(网页制作,网站开发,web开发,从0基础开始的的HTML+CSS+JavaScript。jQuery,Ajax,node,angular框架等到移动端HTML5的项目实战【视频+工具+系统路线图】全栈工程师学习路线以及规划都有整理,分享给小伙伴)点:学习前端,我们是认真的

你可能感兴趣的:(CSS3白色质感3D按钮特效源码)