可以用以下代码实现打赏二维码的显示和隐藏
<!DOCTYPE html><html lang="en"><head>
<meta charset="UTF-8">
<title></title>
<style>
* {
margin: 0;
padding: 0;
list-style: none;
}
#e_coder {
width: 50px;
height: 50px;
background: url("images/e_coder_normal.png") no-repeat;
position: fixed;
top: 40%;
left: 0;
cursor: pointer;
}
#e_app {
position: absolute;
left: 50px;
top: -50px;
/*隐藏*/
display: none;
}
</style></head><body>
<div id="e_coder">
<div id="e_app">
<img src="images/e_coder.jpg" alt="公众号" width="150">
</div>
</div>
<script>
window.onload = function () {
// 获取标签
var coder = document.getElementById("e_coder");
var app = document.getElementById("e_app");
// 鼠标进入
coder.onmouseover = function () {
this.style.background = "url('images/e_coder_selected.png') no-repeat";
app.style.display = "block";
};
// 鼠标离开
coder.onmouseout = function () {
this.style.background = "url('images/e_coder_normal.png') no-repeat";
app.style.display = "none";
};
};
</script></body></html>