站长资源网页制作

CSS+JS实现水滴涟漪动画按钮效果的示例代码

整理:jimmy2025/1/10浏览2
简介代码如下所示:Docum</div> <div class="news_infos"><div id="MyContent"><p>代码如下所示:</p> <div class="htmlcode"> <pre class="brush:css;"> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> .btn{ display: block; width: 300px; height: 100px; margin: 50px; outline: 0; overflow: hidden; position: relative; transition: .3s; cursor: pointer; user-select: none; text-align: center; line-height: 100px; font-size: 50px; background: tomato; color: #fff; border-radius: 10px; } .btn>span{ position: absolute; left: 0; top: 0; width: 100%; height: 100%;} .btn>span:after{ content: ''; position: absolute; background: transparent; border-radius:50%; width: 100%; padding-top: 100%; margin-left: -50%; margin-top: -50%; left: var(--x,-100%); top: var(--y,-100%); } .btn:active{ background: orangered; } .btn>input[type=checkbox]{ display: none } .btn>input[type=checkbox]+span:after{ animation: ripple-in 1s; } .btn>input[type=checkbox]:checked+span:after{ animation: ripple-out 1s; } @keyframes ripple-in{ from { transform: scale(0); background: rgba(0,0,0,.25) } to { transform: scale(1.5); background: transparent } } @keyframes ripple-out{ from { transform: scale(0); background: rgba(0,0,0,.25) } to { transform: scale(1.5); background: transparent } } </style> </head> <body> <label class="btn" tabindex="1"> <input type="checkbox"><span onclick="ripple(this,event)">button</span> </label> </body> <script> function ripple(dom,ev){ console.log(ev) var x = ev.offsetX; var y = ev.offsetY; dom.style.setProperty('--x',x+'px'); dom.style.setProperty('--y',y+'px'); } </script> </html></pre> </div> <p><a href="javascript:;" onclick="showimg('/UploadFiles/2021-03-30/2020082616540154.gif');"><img src="/UploadFiles/2021-03-30/2020082616540154.gif" alt="CSS+JS实现水滴涟漪动画按钮效果的示例代码" onmousewheel="return bbimg(this)" onload="javascript:resizepic(this)" border="0"/></a></p></div> </div> </div> <div class="share"> </div> <div class="nextinfo"> <p>上一篇:<a href="/3g/1/70300.html" title="CSS 中的六个重要选择器(三秒就可以记住)">CSS 中的六个重要选择器(三秒就可以记住)</a></p> <p>下一篇:<a href="/3g/1/70302.html" title="flex是什么及flex布局语法教程详解">flex是什么及flex布局语法教程详解</a></p> </div> <div class="otherlink"> <h2>最新资源</h2> <ul> <li><a href="/3g/1/623703.html" title="群星《奔赴!万人现场 第2期》[FLAC/分轨]">群星《奔赴!万人现场 第2期》[FLAC/分轨]</a></li> <li><a href="/3g/1/623702.html" title="群星《奇妙浪一夏 (上海迪士尼度假区音乐">群星《奇妙浪一夏 (上海迪士尼度假区音乐</a></li> <li><a href="/3g/1/623701.html" title="群星《奇妙浪一夏 (上海迪士尼度假区音乐">群星《奇妙浪一夏 (上海迪士尼度假区音乐</a></li> <li><a href="/3g/1/623700.html" title="【古典音乐】詹姆斯·高威《季节》1993[WA">【古典音乐】詹姆斯·高威《季节》1993[WA</a></li> <li><a href="/3g/1/623699.html" title="贝拉芳蒂《卡里普索之王》SACD[WAV+CUE]">贝拉芳蒂《卡里普索之王》SACD[WAV+CUE]</a></li> <li><a href="/3g/1/623698.html" title="小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE">小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE</a></li> <li><a href="/3g/1/623697.html" title="群星《欢迎来到我身边 电影原声专辑》[32">群星《欢迎来到我身边 电影原声专辑》[32</a></li> <li><a href="/3g/1/623696.html" title="群星《欢迎来到我身边 电影原声专辑》[FL">群星《欢迎来到我身边 电影原声专辑》[FL</a></li> <li><a href="/3g/1/623695.html" title="雷婷《梦里蓝天HQⅡ》 2023头版限量编号低">雷婷《梦里蓝天HQⅡ》 2023头版限量编号低</a></li> <li><a href="/3g/1/623694.html" title="群星《2024好听新歌42》AI调整音效【WAV分">群星《2024好听新歌42》AI调整音效【WAV分</a></li> </ul> </div> </div> <div class="sidebar"> </div> <div class="sidebar"> 友情链接:<a href="http://www.imxmx.com/" title="杰晶网络" target="_blank">杰晶网络</a> <a href="/" title="DDR爱好者之家" target="_blank">DDR爱好者之家</a> <a href="http://www.nqxw.com/" title="南强小屋" target="_blank">南强小屋</a> <a href="http://www.paidiu.com/" title="黑松山资源网" target="_blank">黑松山资源网</a> <a href="http://www.dyhadc.com/" title="白云城资源网" target="_blank">白云城资源网</a> <a href="/sitemap1.xml">站点地图</a> <a href="/sitemap.xml">SiteMap</a> </div> </article> <footer> <p>Design by <a href="http://m.ddrfans.com">DDR爱好者之家</a> <a href="http://m.ddrfans.com">http://m.ddrfans.com</a></p> </footer> <script src="/images3g/nav.js"></script> <script type="text/javascript"> jQuery.noConflict(); jQuery(function() { var elm = jQuery('#left_flow2'); var startPos = jQuery(elm).offset().top; jQuery.event.add(window, "scroll", function() { var p = jQuery(window).scrollTop(); jQuery(elm).css('position', ((p) > startPos) ? 'fixed' : ''); jQuery(elm).css('top', ((p) > startPos) ? '0' : ''); }); }); </script> </body> </html>