web前端|js教程
css3,javascript,按钮水波纹
web前端-js教程
本篇文章通过代码示例,带大家介绍一下css3+javascript实现按钮水波纹效果的方法
地方门户app源码,mac装ubuntu驱动,python爬虫和股票,php putcsv,seo 标签滥用lzw
易语言反编译出源码教程,lxde安装vscode,ubuntu挂在2t机械硬盘,tomcat 安全启动,sqlite默认空字符,城市的二级联动插件,彩票走势图 前端框架,网络爬虫师需要学历,iis php 设置,苗雄seo,杰奇红袖添香在线小说网站源码程序,办公网页模板下载软件,电商网站html模板下载lzw
css3+js实现按钮水纹涟漪效果
微门禁源码,ubuntu查看端口22,tomcat免安装选版本,爬虫大赛图片,外卖侠php,沈北新区实惠的seo推广哪家强lzw
HTML
首先我们用标签定义两个按钮
buttonbutton
CSS3
调整布局样式色彩范围
* { margin: 0; padding: 0; font-family: Poppins, sans-serif; /* 字体 */}body { display: flex; justify-content: center;/* 弹性盒子 */ align-items: center; min-height: 100vh; flex-direction: column; background: #1f2a33;}a { position: relative; display: inline-block; padding: 12px 36px; margin: 10px 0; color: #fff; text-decoration: none; text-transform: uppercase; font-size: 18px; letter-spacing: 2px; border-radius: 40px; overflow: hidden; background: linear-gradient(90deg, #0162c8, #55e7fc);}/* 子伪类选择器 */a:nth-child(2) { background: linear-gradient(90deg, #755bea, #ff72c0);}span { position: absolute; background: #fff; transform: translate(-50%, -50%); pointer-events: none; border-radius: 50%; animation: animate 1s linear infinite;}@keyframes animate { 0% { width: 0px; height: 0px; opacity: 0.5; } 100% { width: 500px; height: 500px; opacity: 0; }}
JavaScript
启用 js 监听事件定时器目的:控制动画和单位时间内点击效果统一
const buttons = document.querySelectorAll(a);buttons.forEach(btn => { //箭头函数 (ES6) btn.addEventListener(click, function (e) { let x = e.clientX - e.target.offsetLeft; let y = e.clientY - e.target.offsetTop;let ripples = document.createElement(span);ripples.style.left = x + px; ripples.style.top = y + px;this.appendChild(ripples); setTimeout(() => { ripples.remove() }, 1000); })})
效果图:
编程视频课程!!