css实现立体质感按钮点击效果代码

代码语言:html

所属分类:表单美化

代码描述:css实现立体质感按钮点击效果代码

代码标签: css立体 质感 按钮

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        @import url("https://fonts.googleapis.com/css?family=Source+Sans+Pro:600&display=swap");
    
    body, html { font-size: 100%; 	padding: 0; margin: 0;}
    
    /* Reset */
    *,
    *:after,
    *:before {
    	-webkit-box-sizing: border-box;
    	-moz-box-sizing: border-box;
    	box-sizing: border-box;
    }
    
    /* Clearfix hack by Nicolas Gallagher: http://nicolasgallagher.com/micro-clearfix-hack/ */
    .clearfix:before,
    .clearfix:after {
    	content: " ";
    	display: table;
    }
    
    .clearfix:after {
    	clear: both;
    }
    
    body{
    	background: #494A5F;
    	color: #D5D6E2;
    	font-weight: 500;
    	font-size: 1.05em;
    	font-family: "Microsoft YaHei","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif;
    }
    
    @-webkit-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;
      }
    }
    @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;
      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"]:focu.........完整代码请登录后点击上方下载按钮下载查看

网友评论0