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>
.box {
width: 200px;
height: 200px;
background-color: #f0f0f0;
border: 2px solid #ccc;
margin: 50px;
transition: border-color 0.3s ease;
}
</style>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<div class="box"></div>
<script>
$(document).ready(function() {
$('.box').hover(
function() {
$(this).css('border-color', 'rgba(255, 255, 0, 0.5)');
},
function() {
$(this).css('border-color', '#ccc');
}
);
});
</script>
</body>
</html>
transform: translateZ(0)
)。通过以上方法,可以有效地实现和优化jQuery鼠标悬停边框发光特效。
领取专属 10元无门槛券
手把手带您无忧上云