問(wèn)題描述
我一直在尋找解決方案,但無(wú)法真正理解,尤其是在創(chuàng)建助手時(shí).我是 Laravel 的新手,我想要一個(gè)簡(jiǎn)單的或詳細(xì)的說(shuō)明,說(shuō)明如何為我的引導(dǎo)程序?qū)Ш綑谠O(shè)置活動(dòng)類.
這是我到目前為止所做的,但無(wú)法完成:
<導(dǎo)航><ul class="nav nav-pills pull-right"><li class=""><a href="{{ url('/') }}">首頁(yè)</a><li {{ Request::is('about*') ?'類=活動(dòng)"': null }}><a href="{{ url('about') }}>關(guān)于我們</a><li><a href={{ url('auth/login') }}">登錄</a></nav><h2 class="">煙草預(yù)防和控制計(jì)劃</h2>
編輯
設(shè)置 class=active"
將使所有導(dǎo)航藥丸處于活動(dòng)狀態(tài).預(yù)期的效果是只有當(dāng)前頁(yè)面的 li
有 active
類.
I've been wondering around looking for solutions, but can't really understand especially when creating helpers. I'm new in Laravel and I want a simple or if not a detailed instruction on how to set the active class for my bootstrap navbar.
Here's what I've done so far, but can't get it done:
<div class="header clearfix">
<nav>
<ul class="nav nav-pills pull-right">
<li class=""><a href="{{ url('/') }}">Home</a>
</li>
<li {{ Request::is('about*') ? ' class="active"' : null }}><a href="{{ url('about') }}">About Us</a>
</li>
<li><a href="{{ url('auth/login') }}">Login</a>
</li>
</ul>
</nav>
<h2 class="">Tobacco Prevention and Control Program</h2>
</div>
EDIT
Setting class="active"
will make all nav-pills active. The intended effect is that only the li
of the current page have the active
class.
<ul class="nav nav-second-level">
<li class="{{ Request::segment(1) === 'programs' ? 'active' : null }}">
<a href="{{ url('programs' )}}" ></i> Programs</a>
</li>
<li class="{{ Request::segment(1) === 'beneficiaries' ? 'active' : null }}">
<a href="{{url('beneficiaries')}}"> Beneficiaries</a>
</li>
<li class="{{ Request::segment(1) === 'indicators' ? 'active' : null }}">
<a href="{{url('indicators')}}"> Indicators</a>
</li>
</ul>
這篇關(guān)于在 Laravel 5 中設(shè)置 Bootstrap 導(dǎo)航欄活動(dòng)類的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!