您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

JS实现鼠标放到图片上产生遮罩效果的代码案例

2024/2/23 7:29:00发布22次查看
本文实例为大家分享了js实现鼠标移动到图片产生遮罩效果的具体代码,供大家参考,具体内容如下
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>mask</title> <style> .pic{ width:300px; height:250px; background:url(icon/product1.jpg) no-repeat; margin:40px auto; } #mask{ width:300px; height:250px; background-color: gray; margin:40px auto; opacity: 0.5; z-index: 1000; } </style> </head> <body> <p class="pic"> <!-- <p id="mask"></p> --> </p> </body> <script> var pic=document.getelementsbyclassname("pic")[0]; var d=document.createelement("p"); pic.onmouseenter=function(){ // var d=document.createelement("p"); d.id="mask"; pic.appendchild(d); }; pic.onmouseleave=function(){ this.removechild(d); }; </script> </html>
效果图:
以上就是js实现鼠标放到图片上产生遮罩效果的代码案例的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product