写在前面
移动端页面,有时候会出现一些固定定位在底部图标,比如购物车等。这时候如果添加一个滑动页面,图标透明度变低,同时 移动到屏幕边进行隐藏,效果如下。
所用原理
监听滑动事件,每次进行滑动时,触发动画,添加定时器,1.4s后显示该图标。具体代码如下:
.fixed-icon{ position: fixed; z-index: 1100; right: 1.7rem; display: flex; justify-content: center; align-items: center; height: 4.1rem; width: 4.1rem; border-radius: 50%; background-color: rgba(128, 128, 128, 0.8); transition: 0.7s ease-in-out; } .fixed-transition{ right: -2.05rem; opacity: 0.4; transition: 1s ease-in-out; }
引入代码如下:
.content{ height: 200vh; } .icon-chat{ width: 2rem; height: 1.9rem; background: url('http://pfpdwbdfy.bkt.clouddn.com/image/test/fixedIconTranstion/wechat.png') no-repeat; background-size: 2rem 1.9rem; }
github代码
总结
以上所述是小编给大家介绍的Vue实现固定定位图标滑动隐藏效果,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对考高分网网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!



