jQuery 水波效果是一种通过 jQuery 库实现的动态视觉效果,通常用于网页上的按钮点击、加载动画等场景。它模拟了水波扩散的效果,给用户带来一种动态和交互的体验。
以下是一个简单的 jQuery 圆形水波效果的示例代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jQuery 水波效果</title>
<style>
.wave-button {
position: relative;
display: inline-block;
padding: 10px 20px;
font-size: 16px;
color: #fff;
background-color: #007bff;
border: none;
border-radius: 5px;
cursor: pointer;
}
.wave {
position: absolute;
border-radius: 50%;
background: rgba(255, 255, 255, 0.3);
pointer-events: none;
opacity: 0;
transition: all 0.5s ease-out;
}
</style>
</head>
<body>
<button class="wave-button">点击我</button>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
$('.wave-button').on('click', function(e) {
var $button = $(this);
var $wave = $('<div class="wave"></div>');
$wave.css({
width: '100px',
height: '100px',
left: e.offsetX - $wave.width() / 2,
top: e.offsetY - $wave.height() / 2
});
$button.append($wave);
setTimeout(function() {
$wave.remove();
}, 1000);
});
});
</script>
</body>
</html>通过以上内容,你应该对 jQuery 水波效果有了全面的了解,并且能够实现和应用这一效果。
没有搜到相关的沙龙