html - 如何在 css 中突出显示菜单。我用了 :active but it does not serve the purpose I expected

标签 html css asp.net-mvc-4

.cshtml

<li>@Html.ActionLink("Tools", "Index", new { Area = "", Controller = "Tools" })</li>

.css

a:active
{
    font-weight: bold;
    background: #F96611;
    border: 3px solid #FFB380;
}

a:active 仅在鼠标单击按下和释放之间起作用。但是我需要菜单在鼠标点击菜单后突出显示。谢谢

最佳答案

你不能添加CSS。 .active 仅适用于点击但不适用于事件状态。您可以使用下面的 jquery 代码在点击时添加类

$('li').click(function() {
  $(this).addClass('youractiveclass'); 
})

关于html - 如何在 css 中突出显示菜单。我用了 :active but it does not serve the purpose I expected,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12174635/

相关文章:

html - 让html链接打开文件夹的方法有哪些

javascript - 在 jQuery 中获取全局样式表的值

javascript - 使用 AJAX 时表单数据未发布到 Controller

c# - 在 ASP.NET MVC4 中——我需要编辑一条记录并向其添加许多(1 到许多)子记录(在顶级记录的编辑模式下)

jquery - MVC万无一失的验证 'Sys is not defined'

javascript - 始终在 Bootstrap-select 中显示一个文本

javascript - 在自定义下拉列表中定位箭头

php - get_option 破坏 wordpress 中的 php 样式表

javascript - .setAttribute 在 for 循环中不起作用 - JavaScript

css - 服务器切换后@font face停止工作