Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How do i make the menu selected item have a different color? tabbed menu ASP.NET MVC

How do i make the menu selected item have a different color? tabbed menu ASP.NET MVC

Scheduled Pinned Locked Moved ASP.NET
questionasp-netcsharpcssarchitecture
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    basilmir
    wrote on last edited by
    #1

    How do i make the menu selected item have a different color? tabbed menu I am using the ASP.NET MVC default template. Well i want the menu i'm in to have a different color. Found this in the css but it does not produce any results. I've searched around the web, most people have solutions that require you to modify the menu alltoghether, having a variable to keep "tabs" on what is selected. Why isn't this working by default? ul#menu li.selected a { background-color: #fff; color: #000000; }

    M J 2 Replies Last reply
    0
    • B basilmir

      How do i make the menu selected item have a different color? tabbed menu I am using the ASP.NET MVC default template. Well i want the menu i'm in to have a different color. Found this in the css but it does not produce any results. I've searched around the web, most people have solutions that require you to modify the menu alltoghether, having a variable to keep "tabs" on what is selected. Why isn't this working by default? ul#menu li.selected a { background-color: #fff; color: #000000; }

      M Offline
      M Offline
      m khansari
      wrote on last edited by
      #2

      Hi You can use this css code

      ul#menu li a:Hover

      {

      background-color: #fff;

      color: #000000;

      }

      I dont understand what you mean in this code

      ul#menu li.selected a

      {

      background-color: #fff;

      color: #000000;

      }

      I think that LI element does not have selecting capability If you want to use Pseudo-class you should write like

      ul#menu li:selected

      but I am not sure that selected be a Pseudo-class

      Mohammad Khansari

      1 Reply Last reply
      0
      • B basilmir

        How do i make the menu selected item have a different color? tabbed menu I am using the ASP.NET MVC default template. Well i want the menu i'm in to have a different color. Found this in the css but it does not produce any results. I've searched around the web, most people have solutions that require you to modify the menu alltoghether, having a variable to keep "tabs" on what is selected. Why isn't this working by default? ul#menu li.selected a { background-color: #fff; color: #000000; }

        J Offline
        J Offline
        Jim G
        wrote on last edited by
        #3

        I stumbled over this too. In order to use the "selected" style for the tab in the standard MVC site.css file, you need to have the selected class be assigned to the <li> rather than the <a> tag.

        ul#menu li.selected a
        {
        background-color: #fff;
        color: #000000;
        }

        So to show the About item selected, for your menu use:

        <ul id="menu">
        <li><%= Html.ActionLink("Home", "Index", "Home")%></li>
        <li><%= Html.ActionLink("Sites", "Index", "Sites")%></li>
        <li class="selected"><%= Html.ActionLink("About", "About", "Home")%></li>
        </ul>

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups