php - How to display Under Line of selected page in header Menu -
i want show under line of selected page in header menu. , header comman file all. header.php
<div id="navbar" class="collapse navbar-collapse"> <ul class="nav navbar-nav" id="nav"> <li class="<?php (basename($_server['php_self'], "index.php") !== false) ? 'active' : '' ?>"><a href="index.php">home</a></li> <li class="<?php (strpos($_server['request_uri'], "jobslist") !== false) ? 'active' : '' ?>"><a href="jobslist.php?id=3">bank job</a></li> <li class="<?php (strpos($_server['request_uri'], "boardresult") !== false) ? 'active' : '' ?>"><a href="boardresult.php">board result</a></li> <li class="<?php (strpos($_server['request_uri'], "admitcard") !== false) ? 'active' : '' ?>"><a href="admitcard.php">admit card</a></li> <li class="<?php (strpos($_server['request_uri'], "anskey") !== false) ? 'active' : '' ?>"><a href="anskey.php">answer key </a></li> <li class="<?php (strpos($_server['request_uri'], "timetable") !== false) ? 'active' : '' ?>"><a href="timetable.php">time table </a></li> </ul> </div>
i see can use php.
you can check current uri on url , if matches add class 'active' on desired li
add underline style :)
this job:
html
<div id="navbar" class="collapse navbar-collapse"> <ul class="nav navbar-nav" id="nav"> <li class="<?php echo (strpos($_server['request_uri'], "index") !== false) ? 'active' : '' ?>"><a href="index.php">home</a></li> <li class="<?php echo (strpos($_server['request_uri'], "jobslist") !== false) ? 'active' : '' ?>"><a href="jobslist.php?id=3">bank job</a></li> <li class="<?php echo (strpos($_server['request_uri'], "boardresult") !== false) ? 'active' : '' ?>"><a href="boardresult.php">board result</a></li> <li class="<?php echo (strpos($_server['request_uri'], "admitcard") !== false) ? 'active' : '' ?>"><a href="admitcard.php">admit card</a></li> <li class="<?php echo (strpos($_server['request_uri'], "anskey") !== false) ? 'active' : '' ?>"><a href="anskey.php">answer key </a></li> <li class="<?php echo (strpos($_server['request_uri'], "timetable") !== false) ? 'active' : '' ?>"><a href="timetable.php">time table </a></li> </ul> </div>
or can try
<li class="<?= (strpos($_server['request_uri'], "index") !== false) ? 'active' : '' ?>"><a href="index.php">home</a></li>
css
#nav li.active { /* apply styles want on active anchors*/ border-bottom: 1px solid red; }
Comments
Post a Comment