简体   繁体   English

我如何在我的引导程序中强调当前页面<nav></nav>

[英]How i can underline the current page inside my bootstrap <nav>

I have the following bootstrap code which define our main menu navigation:-我有以下定义我们的主菜单导航的引导代码:-

<div class="col-xl-9 col-lg-9">
                                <div class="main-menu  d-none d-lg-block">
                                    <nav>
                                        <ul id="navigation">
                                            <li><a href="/">home</a></li>
                                            <li><a href="/home/FAQ">FAQ</a></li>
                                            <li><a href="/home/contact/">Contact</a></li>
                                        </ul>
                                    </nav>
                                </div>
                            </div>

but i need to make the current page underline using bootstrap if possible?但如果可能的话,我需要使用引导程序为当前页面添加下划线?

Put a class in the one that is active and in css give the underline to the class Like this:将 class 放入活动中,并在 css 中为 class 下划线,如下所示:

<li class="active"><a href="/">home</a></li>

css: css:

.active{
    border-bottom: xxxx;
    border-color:xxxx;
    border-style:xxx;
    }

You need some JavaScript for this.为此,您需要一些 JavaScript。 Basically, you need to add a class dynamically, eg active to your active <li> element and then add some styles to this class.基本上,您需要动态添加一个 class,例如active您的活动<li>元素,然后将一些 styles 添加到此 class。 Check this article for further details.查看这篇文章了解更多详情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM