怎么设置访问页面对应的标题高亮显示

发布时间:2021-11-06 18:36:46 作者:柒染
来源:亿速云 阅读:116

这篇文章将为大家详细讲解有关怎么设置访问页面对应的标题高亮显示,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

1 HTML

点击(此处)折叠或打开

  1. <div class="users-body">

  2.   <ul id="menu-list" class="trigger-menu list-inline">

  3.     <li>

  4.       <a href="/users/{{author_id}}?order_by=created_at" onfocus="this.blur()">文章</a>

  5.     </li>

  6.     <li>

  7.       <a href="/users/{{author_id}}" onfocus="this.blur()">动态</a>

  8.     </li>

  9.     <li>

  10.       <a href="/users/{{author_id}}?order_by=commented_at" onfocus="this.blur()">最新评论</a>

  11.     </li>

  12.     <li>

  13.       <a href="/users/{{author_id}}?order_by=top" onfocus="this.blur()">热门</a>

  14.     </li>

  15.     <li>

  16.       <a href="/users/{{author_id}}/following" onfocus="this.blur()">关注用户</a>

  17.     </li>

  18.     <li>

  19.       <a href="/users/{{author_id}}/followers" onfocus="this.blur()">粉丝</a>

  20.     </li>

  21.   </ul>

  22.   {% block user_content %} {% end %}

  23. </div>



2 js
$(function(){
    $(window).on("load hashchange",function(){
    $("#menu-list").find('a').each(function(){
      var url = window.location.protocol + '//' +  window.location.hostname + ':' + location.port
      if (url + $(this).attr('href') == String(window.location)) {
        $(this).addClass("active");
      }
    });
  });
});

3 css
.trigger-menu li a{
  font-size: 15px;
  font-weight: bold;
  color: #a3a3a3;
}

.trigger-menu li a:hover {
  box-shadow:  0 2px  #3d3d3d;
  color: #a6a6a6;
}

.trigger-menu .active {
  box-shadow:  0 2px  #3d3d3d;
  color: #3d3d3d;
}

关于怎么设置访问页面对应的标题高亮显示就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

推荐阅读:
  1. vue如何实现多组关键词对应高亮显示功能
  2. matplotlib subplots如何设置总图的标题

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

html

上一篇:如何在deepin中一键安装喜欢的字体

下一篇:如何理解Apache配置文件中的deny与allow

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》