jquery实现立体视觉滚动差异按钮效果代码

代码语言:html

所属分类:视觉差异

代码描述:jquery实现立体视觉滚动差异按钮效果代码

代码标签: jquery 视觉差异 滚动 按钮

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

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />




    <style>
        /* button variables */
        html {
          height: 100%;
          overflow: hidden;
          background: #777;
        }
        
        /* the perspective set here is the most important declaration for the 3d look of the buttons (values over 1000px make the buttons look almost flat) */
        body {
          margin: 0;
          height: 100%;
          overflow-y: scroll;
          font-family: sans-serif;
          font-size: 16px;
          perspective: 350px;
        }
        
        div {
          width: 600px;
          margin: 0 auto;
          padding: 20px 20px 600px;
          background: #fff;
          transform-style: preserve-3d;
        }
        
        h1, h2 {
          text-align: center;
        }
        
        h1, h2, hr {
          position: relative;
          background: #444;
          color: #fff;
          line-height: 2em;
          margin-left: -50px;
          margin-right: -50px;
          transform-style: preserve-3d;
          transform: translateZ(1px);
        }
        h1::before, h1::after, h2::before, h2::after, hr::before, hr::after {
          content: "";
          position: absolute;
          top: 0;
          width: 50px;
          height: 100%;
          background: #2b2b2b;
        }
        h1::before, h2::before, hr::before {
          left: -50px;
          transform-origin: 100% 0%;
          transform: rotateY(-130deg);
        }
        h1::after, h2::after, hr::after {
          right: -50px;
          transform-origin: 0% 0%;
          transform: rotateY(130deg);
        }
        
        hr {
          border: 0;
          height: 10px;
          background: #444;
        }
        
        button {
          position: relative;
          display: inline-block;
          padding: 4px 16px;
          border: 0;
          min-width: 48px;
          margin: 10px;
          font-size: 24px;
          font-weight: bold;
          background-color: #aad1ee;
          background-image: radial-gradient(ellipse at top, rgba(255, 255, 255, 0.15) 50%, rgba(0, 0, 0, 0));
          color: #222;
          transform-style: preserve-3d;
          transform: translateZ(18px);
          cursor: pointer;
          user-select: none;
          /* double colon syntax for pseudo elements because IE8 doesn't need to see them (no transforms) */
          /* pushing the button down; done with animations with steps because transitions are too buggy and jumpy */
        }
        button:focus {
          outline: none;
        }
        button::before, button::after {
          position: absolute;
          width: 100%;
          height: 100%;
          left: 0;
          top: 0;
          background: #4098d9;
          transform-origin: 0% 0%;
        }
        button::before {
          content: "";
          height: 18px;
          background: #6aafe1;
          transform: rotateX(-90deg);
        }
        button::after {
          content: "";
          width: 18px;
          transform: rotateY(90deg);
        }
        button.top-half::before {
          top: auto;
          bottom: 0;
          background: #267ebf;
          transform-origin: 100% 100%;
          transform: rotateX(90deg);
        }
        button.left-half::after {
          left: auto;
          right: 0;
          transform-origin: 100% 100%;
          transform: rotateY(-90deg);
        }
        button:active {
          animation: button 80ms steps(20) both;
        }
        button:active::before {
          animation: buttonbefore 80ms steps(20) both;
        }
        button:active::after {
          animation: buttonafter 80ms steps(20) both;
        }
        
        @keyframes button {
          to {
            transform: translateZ(9px);
          }
        }
        @keyframes buttonbefore {
          to {
            height: 9px;
          }
        }
        @keyframes buttonafter {
          to {
            width: 9px;
          }
        }
        /* hide pseudo elements in IE9 and IE10 (no 3D transforms) */
        @media screen and (min-width: 0\0) {
          button::before, button::after {
            display: none;
          }
        }
        /* hide pseudo elements in non-webkit Opera) */
        x:-o-prefocus, button::before, button::after {
          display: none;
        }
    </style>


</head>

<body>

    <div>
        <h1>3D Parallax Buttons</h1>

        <p>Observe the 3D effect as you scroll around. The larger the monitor you use, the bigger the effect you'll be able to see.</p>
        <p></p>

        <button>!</button>
        <button>!</button>
        <button>!</button>
        <button>!</button>
        <button>!</button>
        <button>!</button>
        <button>!</button.........完整代码请登录后点击上方下载按钮下载查看

网友评论0