项目开发需要实现这个效果,当鼠标划过这个按钮的时候,会显示出指定的图片出来
HTML代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta target="_blank">
<link rel="shortcut icon" href="../images/羊羊.png" type="image/x-icon">
<link rel="stylesheet" href="../CSS/bootstrap.min.css">
<title>Stukk Web</title>
</head>
<body>
<!-- Button trigger modal -->
<button class="btn btn-warning btn-lg" data-toggle="popover" data-trigger="hover" data-placement="bottom" >
懒洋洋按钮
</button>
</body>
<script src="../JS/jquery-3.6.0.js">
</script>
<script src="../JS/popper.min.js">
</script>
JQuery代码
$(function (){
$("[data-toggle='popover']").popover({
animation:true,//淡入淡出
html:true,//允许插入html代码
container:"body",
content:"<img src='../images/懒洋洋.jpg' style='width:20px'>",//插入图片的路径 及 样式
});
});