|CSS3之3D魔方鼠标控制酷炫效果( 二 )
本文插图
CSS3之3D魔方鼠标控制酷炫效果
然后我们通过JS控制展开和收起效果
var clickNum = 1;//点击次数 $('.box').children().click(function () { // 如果点击次数是奇数就展开 , 偶数就收起 if (clickNum % 2 == 0) { // 收起 $('.out-front').css({ transform: 'translateZ(100px)' }); $('.out-back').css({ transform: 'translateZ(-100px) rotateY(180deg)' }); $('.out-left').css({ transform: 'translateX(-100px) rotateY(-90deg)' }); $('.out-right').css({ transform: 'translateX(100px) rotateY(90deg)' }); $('.out-top').css({ transform: 'translateY(-100px) rotateX(90deg)' }); $('.out-bottom').css({ transform: 'translateY(100px) rotateX(-90deg)' }); } else { // 展开 $('.out-front').css({ transform: 'translateZ(200px)' }); $('.out-back').css({ transform: 'translateZ(-200px) rotateY(180deg)' }); $('.out-left').css({ transform: 'translateX(-200px) rotateY(-90deg)' }); $('.out-right').css({ transform: 'translateX(200px) rotateY(90deg)' }); $('.out-top').css({ transform: 'translateY(-200px) rotateX(90deg)' }); $('.out-bottom').css({ transform: 'translateY(200px) rotateX(-90deg)' }); } clickNum++; }); // box 的所有子元素添加鼠标手势样式 $('.box').children().mouseenter(function () { $(this).css({ cursor: 'pointer' }); });OK , 这样我们的 CSS3 3D魔方鼠标控制酷炫效果就实现了 。
结语
大家学到了什么?JS鼠标事件都了解了吧?CSS3 3D场景都学会了吗?
关注我 , 学习更多前端知识 , 但不止于前端哦!
小伙伴们 , 有问题可以评论区留言哦 , 欢迎大家点评 。 需要源码的小伙伴可以购买 , 私信我哦 。
谢谢大家一直以来的支持 。
推荐阅读
- 晚九品读|BTCMAX交易所将于7月5日正式上线QBC魔方
- 秘乐魔方抓住直播风口,为新零售按下加速键
- 驱动之家 两种手感 259元,小米众筹爆品鼠标回归:升降变形
- 小米|小米众筹爆品鼠标回归:升降变形 两种手感 259元
- 3种操控方式 雷柏V330幻彩RGB游戏鼠标上市
- 美观即是正义,衡文电脑周边的温馨陪伴
- 触摸未来 手感好,性能强,小米游戏鼠标体验,有线无线双模
- 【外星人】你的红色和我的红色一样吗?
- 狸叔玩数码|618换上心念已久的小米游戏鼠标,双模自带快速瞄准键,贱驴退休
- 比特魔方|UNITY3D、Unreal、Cocos2DX...介绍「游戏引擎」江湖的几个大玩家
