<style>
* {
margin: 0;
padding: 0;
}
p {
display: inline-block;
background-color: #eee;
width: 90px;
height: 50px;
display: inline-block;
line-height: 50px;
padding-left: 20px;
text-decoration: none;
}
li {
list-style: none;
color: #000;
}
ul li {
width: 88px;
height: 40px;
line-height: 40px;
color: #000;
border: 1px solid rgb(221, 221, 205);
border-top: none;
padding-left: 20px;
}
ul li:hover {
background-color: rgb(227, 228, 213);
color: orange;
}
ul {
width: 110px;
display: none;
}
</style>
</head>
<body>
<p>微博</p>
<ul>
<li>私信</li>
<li>评论</li>
<li>@我</li>
</ul>
<script>
var p = document.querySelector('p');
var ul = document.querySelector('ul');
p.onmouseover = function () {
p.style.color = 'orange';
ul.style.display = 'block';
}
p.onmouseout = function () {
p.style.color = '#000';
ul.style.display = 'none';
}
ul.onmouseover = function () {
ul.style.display = 'block';
}
ul.onmouseout = function () {
ul.style.display = 'none';
}
</script>
</body>
新浪下拉菜单案例
最新推荐文章于 2024-03-21 03:48:40 发布