鼠标悬停显示三个下拉列表按钮
代码部分:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>数据更新页面</title>
<style type="text/css">
#hoverBox {
position: relative;
width: 200px;
height: 50px;
background-color: #ddd;
text-align: center;
line-height: 50px;
cursor: pointer;
}
#hoverBox::after {
content: "";
position: absolute;
bottom: -10px;
left: 50%;
transform: translateX(-50%);
border-style: solid;
border-width: 10px 10px 0 10px;
border-color: #fff transparent transparent transparent;
display: none;
}
#popup {
display: none;
position: absolute;
top: calc(100% + 10px);
left: 50%;
transform: translateX(-50%);
background-color: #f9f9f9;
border: 1px solid #ddd;
padding: 10px;
width: 200px;
text-align: center;
overflow: hidden;
}
#hoverBox:hover::after {
display: block;
border-color: red transparent transparent transparent;
}
</style>
</head>
<body>
<div style="margin-top:100px;">
<div id="hoverBox">
鼠标悬停我试试
<div id="popup">这是一个弹框!
<div class="App">原生App安装包</div>
<div class="wgt">wgt资源包</div>
</div>
</div>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
const hoverBox = document.getElementById('hoverBox');
const popup = document.getElementById('popup');
hoverBox.addEventListener('mouseenter', function () {
popup.style.display = 'block';
});
hoverBox.addEventListener('mouseleave', function () {
popup.style.display = 'none';
});
// 监听点击事件
// 监听点击事件
const appElement = document.querySelector('.App');
const wgtElement = document.querySelector('.wgt');
appElement.addEventListener('click', function() {
console.log('1111');
});
wgtElement.addEventListener('click', function() {
console.log('2222');
});
</script>
</body>
</script>
</html>