Jump to content

Navigation Bar problem


Techrits

Recommended Posts

Hello friends,

I need to display which link/menu is selected in the navigation bar of my website.

My navigation bar contains diff menus like home, contact us etc. if people selects contact us then it should stay highlighted.

So please reply if you know how to do this in php/css/html only (because I don't have knowledge of other web development lang.)

 

Thanks and regards.

Link to comment
Share on other sites

Wherever you output the menu, check to see which page you're on and change the color of that menu item.

 

Exactly correct but I'm having only one nav-bar in my site (which is unique to all menus and pages) and to make code reliable I include that code (nav-bar) in one file and using php all pages includes that same file so the thing you mentioned will not work here.

Link to comment
Share on other sites

Exactly correct but I'm having only one nav-bar in my site (which is unique to all menus and pages) and to make code reliable I include that code (nav-bar) in one file and using php all pages includes that same file so the thing you mentioned will not work here.

This is the only way my suggestion will work.  Inside your nav include file, when you print the menus, change the color of the menu item which corresponds to the page you're on. 
Link to comment
Share on other sites

Yes but how to do it with css
It's your page, not mine.  Change the colors, make it bold, whatever.  You "do it with CSS" the same way you do anything with CSS: give it a special class.

 

and html as which conditions should I check I need hint on this point.
This...makes no sense, but again, it's your site and not mine.  How do you determine which page you're on?  However you determine that (url, filename being called, a variable called $page), check that against the nav items you're printing when you print them.  If the page you're on matches the nav item you're about to print, make it a different color or size or whatever.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.