如何在页面中选中侧边栏菜单时更改菜单背景颜色?当我在不同的 html 文件(命名为 sidebar.html)中创建此侧边栏菜单并将该 html 文件包含在我的主页中时。这是我的代码:
Sidebar.html
<div id="menuwrapper" >
<ul>
<li>
<a href="#"><img src="image/dashboard-icon.png" id="logimg" alt="Smiley face" height="" width="">
<strong style="margin-left: 7px;"> Dashboard</strong>
<span class="glyphicon glyphicon-menu-right" style="padding-left: 113px; font-weight: bold;"></span>
</a>
</li>
<li>
<a href="#"><img src="image/em_current_openings_icon.png" id="logimg" alt="Smiley face" height="" width="">
<strong style="margin-left: 7px;font-family: sans-serif;">Curent Openings</strong>
<span class="glyphicon glyphicon-menu-right" style="padding-left: 88px; font-weight: bold;"></span>
</a>
</li>
<li>
<a href="renumeration.html"> <img src="image/em_remuneration_icon.png" id="logimg" alt="Smiley face" height="" width="">
<strong style="margin-left: 7px;font-family: sans-serif;">Remuneration</strong>
<span class="glyphicon glyphicon-menu-right" style="padding-left: 103px; font-weight: bold;"></span>
</a>
</li>
</ul>
</div>
renumeration.html
<html>
<head>
</head>
<body>
<div ng-include src="'sidebar.html'"></div>
</body>
</html>
最佳答案
我想你的意思很简单:hover css 伪选择器? 尝试将此添加到页面:
<style>
li:hover{
background-color: #ccc;
}
</style>
或者还有一个:active选择器
关于javascript - 在侧边栏中选择特定菜单时更改菜单背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38760989/