学习JavaScript鼠标响应事件_javascript技巧
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了学习JavaScript鼠标响应事件_javascript技巧,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含5153字,纯文字阅读大概需要8分钟。
内容图文
![学习JavaScript鼠标响应事件_javascript技巧](/upload/InfoBanner/zyjiaocheng/329/eae4b2bfb23646d8b9e1fe4e1f953851.jpg)
如何实现捕抓鼠标事件,当鼠标滑动时,获取当前鼠标的坐标,接着在一个透明区域里绑定捕抓的位移,这样就能在模拟的透明区域里实现鼠标滑动的模型。
效果图:
HTML代码:
the mouse 默认 圆0.25 0.5 0.75 1鼠标感应器(the mouse sensor)
CSS代码:
* { margin: 0; padding: 0; box-sizing: border-box; } body { position: absolute; text-align: center; height: 100%; width: 100%; } .main{ position: relative; margin: 0 auto; height: 100%; background-color: rgb(48, 70, 82) } .main .content{ position:absolute; display: inline-block; top:50%; left:50%; margin-left: -300px; margin-top: -150px; width: 600px; height: 300px; line-height: 300px; /*overflow: hidden;*/ background: radial-gradient(ellipse farthest-corner, rgb(115, 176, 198) 0%, #888 100%); background: -webkit-radial-gradient(ellipse farthest-corner, rgb(115, 176, 198) 0%, #888 100%); box-shadow: 2px 3px 8px rgba(67, 50, 124 ,.6),0px 0px 8px rgba(67, 50, 124 ,.6); } .main .content .content-nav-top{ display: none; position: absolute; margin-top: -50px; height: 50px; width: 300px; } .main .content .content-nav-top >span{ display: block; float: left; font-size: 16px; font-weight: normal; margin-right:1px; width: 50px; height: 50px; line-height: 50px; background-color: rgba(251, 214, 146,.3); box-shadow: 0px 4px 13px rgb(222,222,222,1); cursor: pointer; } .main .content .content-nav-top >span:nth-child(1){ border-radius:0 ; } .main .content .content-nav-top >span:nth-child(2){ border-radius:50% ; } .main .content .content-nav-top >span:nth-child(3){ border-radius:0; } .main .content .content-nav-top >span:nth-child(4){ border-radius: 50% ; } .main .content .content-nav-left{ display: none; position: absolute; margin-left: -50px; width: 50px; height: 300px; } .main .content .content-nav-left >span{ display: block; font-size: 16px; font-weight: normal; margin-bottom:1px; width: 50px; height: 50px; line-height: 50px; background-color: rgb(85, 145, 140); box-shadow: 0px 4px 13px rgb(222,222,222,1); border-radius:50% 0 0 50% ; cursor: pointer; } .box{ position: relative; float: left; width: 49.9%; height: 100%; border-right-style: solid; border-right-width: 1px; border-right-color: rgba(211,211,211,.5); color:rgb(99, 84, 168); text-shadow: 0px 1px 0px #888,1px 0px 0px #888,0px 0px 1px #888; } .block{ float: right; width: 50%; height: 100%; }
JS代码:
这里的鼠标箭头也可换成自己喜欢的图标,模拟鼠标区域的颜色也可自由变换,模拟区域的效果也可是点状的,也可以是线状的,动画效果等等,这个自由发挥吧。
以上就是针对JavaScript鼠标响应事件进行的详细介绍,希望对大家的学习有所帮助。
内容总结
以上是互联网集市为您收集整理的学习JavaScript鼠标响应事件_javascript技巧全部内容,希望文章能够帮你解决学习JavaScript鼠标响应事件_javascript技巧所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。