Home  >  Q&A  >  body text

css - 如何实现鼠标移上去的时候一个div元素模糊变清晰

有点类似于word2007里面的那个鼠标跟随面板一样的功能,就是计算鼠标离元素的距离,距离越近元素越清晰,反之越模糊,如何实现?

大家讲道理大家讲道理2721 days ago745

reply all(3)I'll reply

  • PHPz

    PHPz2017-04-17 13:42:04

    Refer to the mouseenter event method. The mouseenter reference example is as follows

    $('p').mouseenter(function(){    
        $(this).animate({
            opacity:0
        
        });
    });

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 13:42:04

    1. For one or two pictures: make a blurry picture and put it on top to control its transparency);
    2. For many pictures: you can take a look at blur.js , use it to create a blurred picture and put it on top to control its transparency; (but this thing consumes more resources, and too many pictures will be very slow).

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 13:42:04

    I don’t know if my understanding is different from the answer above.

    I think your requirement is to compare the position of the mouse with the center point of the element, and then confirm a rule to blur your element.

    reply
    0
  • Cancelreply