美文网首页CSS 专题叙述
Blind your eyes 炫酷按钮

Blind your eyes 炫酷按钮

作者: 科哚洛夫 | 来源:发表于2018-05-11 16:10 被阅读18次
按钮动画

复制代码即可用

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>demo</title>
  <style>
         
          .button {
              position: relative;
              appearance: none;
              background: #f72359;
              padding: 1em 6em;
              border: none;
              color: white;
              font-size: 1.2em;
              cursor: pointer;
              outline: none;
              overflow: hidden;
              border-radius: 100px;
        }
  
        .button::before {
               --size: 0;
               content: '';
              position: absolute;
              left: var(--x);
              top: var(--y);
              width: var(--size);
              height: var(--size);
              background: radial-gradient(circle closest-side, #4405f7, transparent);
              transform: translate(-50%, -50%);
              transition: width .2s ease, height .2s ease;
        }
       /* 这一步的目的是 上一步的颜色会吧button文本覆盖掉。 在这里重新添加一个!  */
        .button::after{
               content: 'Niu bi class';
               position: absolute;
               z-index: 2;
               left: 0;
               right: 0;
        }

      .button:hover::before {
                --size: 400px;
      }

  </style>
</head>
<body>
  <button class="button">Niu bi class</button>
 
<script>
// 获取到鼠标的位置。
document.querySelector('.button').onmousemove = (e) => {
        const x = e.pageX - e.target.offsetLeft
        const y = e.pageY - e.target.offsetTop
        e.target.style.setProperty('--x', `${ x }px`)
        e.target.style.setProperty('--y', `${ y }px`)
}
</script>
</body>
</html>


相关文章

  • Blind your eyes 炫酷按钮

    复制代码即可用

  • 假如给我三天光明

    Use your eyes as if tomorrow you would be stricken blind....

  • Are your spiritual eyes blind?

    “Lift up your eyes on high and see: Who created these? He...

  • 道德经·第十二章

    Chapter 12 The five colors blind the eyes of man; The fiv...

  • Learn & Do.   -kids4

    1.Close your eyes. 2.Open your eyes. 3.Show me your hands...

  • You are the April of this world

    Your laughter is a panacea for all your sorrows Your eyes...

  • 2017-09-01

    The eyes are blind.One must look with the heart. 眼睛是看不见的。...

  • 【SPN】Eyes, your eyes

    清晨。 阳光透过没有拉紧的窗帘隐隐绰绰地闪进旅馆的房间,灰尘在微光里走走停停。Dean从宿醉中睁开眼睛,嘴里还留有...

  • IN YOUR EYES

    恍惚间一下子到了五月底,此时的浏阳,并不是很热,下雨的天气,甚至带着点凉意。今天办公室里的老师说,去年的这个时候,...

  • in your eyes

    你眼中的世界。 小清新科幻爱情故事,绝佳的bgm和充满创意的故事线让人简直欲罢不能。 一天从早到晚都有些闷闷的,大...

网友评论

    本文标题:Blind your eyes 炫酷按钮

    本文链接:https://www.haomeiwen.com/subject/yegfdftx.html