Php 如何在使用';包括导航和x27;功能
我将导航存储在一个单独的Php 如何在使用';包括导航和x27;功能,php,laravel,twitter-bootstrap,Php,Laravel,Twitter Bootstrap,我将导航存储在一个单独的nav.blade.php文件中,并使用@include('includes.nav')函数将其调用到每个页面中。这非常有效,但我无法突出显示当前页面 我已经尝试添加了一些其他人在这里描述的代码,但我一直迷路。我是新的编码和遗漏的东西,我需要一个循序渐进的指导!我认为这将有助于其他使用引导导航 这是我的nav.blade.php,使用@include('includes.nav') navbar先生{ 填充:10px; 字体大小:1.15rem; 字体:“Helveti
nav.blade.php
文件中,并使用@include('includes.nav')
函数将其调用到每个页面中。这非常有效,但我无法突出显示当前页面
我已经尝试添加了一些其他人在这里描述的代码,但我一直迷路。我是新的编码和遗漏的东西,我需要一个循序渐进的指导!我认为这将有助于其他使用引导导航
这是我的nav.blade.php
,使用@include('includes.nav')
navbar先生{
填充:10px;
字体大小:1.15rem;
字体:“Helvetica Neue”;
/*字体系列:“Helvetica Neue”,Helvetica,Arial*/
}
李{
浮动:左;
文字装饰:无;
填充:0px;
列表样式类型:无;
}
-
-
-
@客人
-
@if(Route::has('register'))
-
@恩迪夫
@否则
-
@csrf
@终客
下面是我的一个网页的示例,说明了这个问题
<head>
@include('includes.head')
</head>
<body>
<h1>Page content</h1>
<p>This page calls the navigation from a separate page called head.blade.php. In that page I have a nav with many link, non of which are active. If I make one of them active, then all pages on my website will show that one page as active.</p>
</body>
</html>```
@include('includes.head')
页面内容
此页面从名为head.blade.php的单独页面调用导航。在那个页面中,我有一个带有许多链接的导航,其中没有一个是活动的。如果我使其中一个页面处于活动状态,那么我网站上的所有页面都将显示该页面为活动页面
```
谢谢,但是我应该把代码放在哪里?我真的是一个新手,发现自己陷入了一片混乱的代码中!别担心。你把它放在你想要激活的a标签上。我把你的链接复制到了关于页面。我会用更多的代码更新我的答案。问题是,我只需在标准引导导航链接中写入
active
,就可以激活选项卡。但由于我的所有页面都有一个导航,而我的实际网页没有导航,所以没有地方向选项卡添加代码!如果我向导航上的导航链接添加代码,它将立即显示在所有页面上。我在“说明”中添加了我的一个网页示例,说明了问题。使用上面的代码,除非当前路径在有条件地添加active
类时匹配,否则所有链接都不会处于活动状态。你试过了吗?
<head>
@include('includes.head')
</head>
<body>
<h1>Page content</h1>
<p>This page calls the navigation from a separate page called head.blade.php. In that page I have a nav with many link, non of which are active. If I make one of them active, then all pages on my website will show that one page as active.</p>
</body>
</html>```
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link @if(Request::is('welcome')) active @endif" href="welcome">Group Listings</a>
</li>
<li class="nav-item">
<a class="nav-link @if(Request::is('about')) active @endif" href="/about">About</a>
</li>
<li class="nav-item">
<a class="nav-link @if(Request::is('contact')) active @endif" href="/contact">Contact</a>
</li>
</ul>
@if(Request::is('route-name')) active @endif"