• <bdo id='zd2WV'></bdo><ul id='zd2WV'></ul>

      <small id='zd2WV'></small><noframes id='zd2WV'>

    1. <tfoot id='zd2WV'></tfoot>
      <legend id='zd2WV'><style id='zd2WV'><dir id='zd2WV'><q id='zd2WV'></q></dir></style></legend>
        <i id='zd2WV'><tr id='zd2WV'><dt id='zd2WV'><q id='zd2WV'><span id='zd2WV'><b id='zd2WV'><form id='zd2WV'><ins id='zd2WV'></ins><ul id='zd2WV'></ul><sub id='zd2WV'></sub></form><legend id='zd2WV'></legend><bdo id='zd2WV'><pre id='zd2WV'><center id='zd2WV'></center></pre></bdo></b><th id='zd2WV'></th></span></q></dt></tr></i><div id='zd2WV'><tfoot id='zd2WV'></tfoot><dl id='zd2WV'><fieldset id='zd2WV'></fieldset></dl></div>

        将鼠标悬停在按钮上后圆圈跟随光标

        Circle follow cursor after hover on button(将鼠标悬停在按钮上后圆圈跟随光标)

          <tbody id='mCneI'></tbody>
            <legend id='mCneI'><style id='mCneI'><dir id='mCneI'><q id='mCneI'></q></dir></style></legend>
              <i id='mCneI'><tr id='mCneI'><dt id='mCneI'><q id='mCneI'><span id='mCneI'><b id='mCneI'><form id='mCneI'><ins id='mCneI'></ins><ul id='mCneI'></ul><sub id='mCneI'></sub></form><legend id='mCneI'></legend><bdo id='mCneI'><pre id='mCneI'><center id='mCneI'></center></pre></bdo></b><th id='mCneI'></th></span></q></dt></tr></i><div id='mCneI'><tfoot id='mCneI'></tfoot><dl id='mCneI'><fieldset id='mCneI'></fieldset></dl></div>

              <small id='mCneI'></small><noframes id='mCneI'>

                <tfoot id='mCneI'></tfoot>
                  <bdo id='mCneI'></bdo><ul id='mCneI'></ul>
                  本文介绍了将鼠标悬停在按钮上后圆圈跟随光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试像在这个网站上一样重新制作悬停:

                  I'm trying to remake hover like on this website:

                  https://www.samsaraubud.com/

                  当您将鼠标悬停在一个按钮上(并且是唯一一个按钮.我不想在整个网站上圈子)时,光标周围会出现一个圆圈.输入鼠标跟随"后,我从 codepen 尝试了很多解决方案,但没有任何效果.

                  When you hover over a button (and only button. I don't want circle over whole website), a circle appers around cursor. I tried so many solutions from codepen after typing "mouse follow" but nothing works.

                  我有这样的按钮:

                  https://codepen.io/Aventadorrre/pen/mdyPJbv

                  body {
                    padding: 100px;
                    margin: auto;
                  }
                  
                  a {
                    color: red;
                    border: 2px solid red;
                    padding: 20px 50px;
                  }

                  <a href="#">Button</a>

                  当我悬停按钮时如何围绕鼠标(跟随鼠标)转圈?

                  and how to make circle around mouse (following mouse) when i hover button?

                  推荐答案

                  考虑一个 radial-gradient 作为背景,你使 fixed 然后简单地根据光标

                  Consider a radial-gradient as background that you make fixed then simply adjust the position based on the cursor

                  var h =document.querySelector('.cursor');
                  
                  document.body.onmousemove = function(e) {
                    /* 15 = background-size/2 */
                    h.style.setProperty('background-position',(e.clientX - 15)+'px '+(e.clientY - 15)+'px');
                  }

                  body {
                    padding: 100px 0;
                  }
                  
                  a.cursor {
                    color: red;
                    border: 2px solid red;
                    padding: 20px 50px;
                    background:
                      radial-gradient(farthest-side, 
                       transparent calc(100% - 3px),
                       red calc(100% - 2px) calc(100% - 1px),
                       transparent 100%) 
                       fixed /* Fixed to the screen*/ 
                       no-repeat; /* Don't repeat*/
                  
                    background-size:30px 30px; /* Control the size of the circle */
                    
                  }

                  <a class="cursor" href="#">Button</a>

                  如果你想要文字上方的圆圈考虑伪元素和相同的技巧:

                  If you want the circle above the text consider pseudo element and the same trick:

                  var h =document.querySelector('.cursor');
                  
                  document.body.onmousemove = function(e) {
                    h.style.setProperty('background-position',(e.clientX - 15)+'px '+(e.clientY - 15)+'px');
                  }

                  body {
                    padding: 100px 0;
                  }
                  
                  a.cursor {
                    color: red;
                    border: 2px solid red;
                    padding: 20px 50px;
                    background-size:0 0; 
                    position:relative;
                  }
                  a.cursor::after {
                    content:"";
                    position:absolute;
                    top:0;
                    left:0;
                    right:0;
                    bottom:0;
                    background:
                      radial-gradient(farthest-side, 
                       blue  calc(100% - 1px),
                       transparent 100%) 
                       fixed /* Fixed to the screen*/ 
                       no-repeat; /* Don't repeat*/
                    background-size:30px 30px;
                    background-position:inherit;
                  }

                  <a class="cursor" href="#">Button</a>

                  这篇关于将鼠标悬停在按钮上后圆圈跟随光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Move link image 5px up on hover(悬停时将链接图像向上移动 5px)
                  How do I inspect CSS pseudo classes with firebug?(如何使用 firebug 检查 CSS 伪类?)
                  Why doesn#39;t CSS hover work on table rows when the cells inside the rows have class names?(当行内的单元格具有类名时,为什么 CSS 悬停在表格行上不起作用?)
                  Hover image - display div over it(悬停图像 - 在其上显示 div)
                  How to apply a CSS class on hover to dynamically generated submit buttons?(如何在悬停时将 CSS 类应用于动态生成的提交按钮?)
                  Differences between CSS3 :hover and :focus?(CSS3 :hover 和 :focus 的区别?)

                    • <small id='Sr0ll'></small><noframes id='Sr0ll'>

                        • <bdo id='Sr0ll'></bdo><ul id='Sr0ll'></ul>

                          <tfoot id='Sr0ll'></tfoot>
                          <i id='Sr0ll'><tr id='Sr0ll'><dt id='Sr0ll'><q id='Sr0ll'><span id='Sr0ll'><b id='Sr0ll'><form id='Sr0ll'><ins id='Sr0ll'></ins><ul id='Sr0ll'></ul><sub id='Sr0ll'></sub></form><legend id='Sr0ll'></legend><bdo id='Sr0ll'><pre id='Sr0ll'><center id='Sr0ll'></center></pre></bdo></b><th id='Sr0ll'></th></span></q></dt></tr></i><div id='Sr0ll'><tfoot id='Sr0ll'></tfoot><dl id='Sr0ll'><fieldset id='Sr0ll'></fieldset></dl></div>

                              <tbody id='Sr0ll'></tbody>
                          1. <legend id='Sr0ll'><style id='Sr0ll'><dir id='Sr0ll'><q id='Sr0ll'></q></dir></style></legend>