html 突出显示选项卡:版本1

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 突出显示选项卡:版本1相关的知识,希望对你有一定的参考价值。

# Here's my solution which I think is the best way to highlight the current page:
# Define a navigation list on your _config.yml like this:

navigation:
  - title: blog
    url: /blog/
  - title: about
    url: /about/
  - title: projects
    url: /projects/

# Then in your _includes/header.html file you must loop through the list to check if the current page (page.url) resembles any item of the navigation list, if so then you just set the active class and add it to the <a> tag:
<nav>
  {% for item in site.navigation %}
    {% assign class = nil %}
    
    {% if page.url contains item.url %}
      {% assign class = 'active' %}
    {% endif %}
    
    <a href="{{ item.url }}" class="{{ class }}">
        {{ item.title }}
    </a>
  {% endfor %}
</nav>

<!-- 
And because you're using the contains operator instead of the equals = operator, you don't have to write extra code to make it work with URLs such as '/blog/post-name/' or 'projects/project-name/'. So it works really well.

P.S: Don't forget to set the permalink variable on your pages. 
-->

以上是关于html 突出显示选项卡:版本1的主要内容,如果未能解决你的问题,请参考以下文章

html 突出显示选项卡:版本4

html 突出显示选项卡:版本3

html 突出显示选项卡:版本2

更改 UIPicker 突出显示的选项卡宽度

CSS 突出显示活动选项卡

在 PHP 中使用 URL 突出显示当前导航选项卡