
说明
1、鼠标跟随就是元素会跟随着鼠标的移动,而作出相对应的运动。
2、为了能够监控当前鼠标的位置,我们只需在页面上铺上元素即可。
实例
<div> <div></div> <div></div> <div></div> <div></div> ...//100个 </div>
.g-container{
position:relative;
width:100vw;
height:100vh;
}
.position{
position:absolute;
width:10vw;
height:10vh;
}
@for$ifrom0through100{
$x:$i%10;
$y:($i-$x)/10;
.position:nth-child(#{$i+1}){
top:#{$y*10}vh;
left:#{$x*10}vw;
}
.position:nth-child(#{$i+1}):hover{
background:rgba(255,155,10,.5)
}
}
以上就是CSS鼠标跟随的原理,希望对大家有所帮助。更多编程基础知识学习:python学习网
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
















































暂无评论内容