又一款跟隨鼠標效果,光標指針下的“方塊”,鼠標移到哪里,方塊就跟到哪里,運用DIV+CSS技術實現,兼容多種主流瀏覽器。代碼分享給大家供參考。
演示:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>跟隨鼠標的方塊</title><meta http-equiv="content-type" content="text/html;charset=gb2312"><style type="text/css">#a{width:15px;height:15px;font-size:0px;border:solid 1px red;background-color:red;position:absolute;border:1px solid #000;}</style></head><body><div id="a"></div><script type="text/javascript">window.onload=function(){var d=document;d.attachEvent?d.attachEvent("onmousemove",bb):d.addEventListener("mousemove",bb,false)}function bb(oEvent){var t=document.getElementById("a");var o=oEvent||window.event;t.style.left=o.clientX-t.offsetWidth/2+'px';t.style.top=o.clientY-t.offsetHeight/2+'px';}</script></body></html><div style="text-align:center;margin:30px 0 0 0;"><hr style="color:#999;height:1px;">如不能顯示效果,請按Ctrl+F5刷新本頁,更多網頁代碼:<a href='http://www.vxbq.cn/' target='_blank'>http://www.vxbq.cn/</a></div>提示:可修改后代碼再運行!
上一篇 小刀:網站為什么很久都不更新百度快照
下一篇 Access入門教程 10.2 使用表達式生成器
程序員人生,我編程,我富裕,記住wfuyu網,php教程,php學習,php手冊,CMS模版制作
聲明:本站大部分內容是作者原創,少部分收集于互聯網供大家一起學習,原版權很多不明,如有侵權請聯系本站,謝謝!
粵ICP備14040726號-1?? 2015-2020 程序員人生 版權所有