简体   繁体   中英

Change color <a> when click (asp.net mvc 4 visual studio 2012)?

My layout code

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
    @Scripts.Render("~/bundles/jquery")
    @RenderSection("scripts", required: false)
    <style>
        .art-hmenu li a {
            background-color: grey;
            color: yellow;            
        }
    </style>
</head>
<body>
    <div class="art-nav-inner">
        <ul class="art-hmenu">
            <li><a href="/Home/Index">Home</a></li>
            <li><a href="/About/Index">Contacts</a></li>
        </ul>
    </div>
    <div>
        @RenderBody()
    </div>
</body>
</html>

when I click link Home, I want it will change color menu Home when I click hyper link Contact, it will change color menu Contact and remove color menu Home

How can I achieve this?

thanks!

Try this.

.art-hmenu li a:link {color:#FF0000;}      /* unvisited link */
.art-hmenu li a:visited {color:#00FF00;}  /* visited link */
.art-hmenu li a:hover {color:#FF00FF;}  /* mouse over link */
.art-hmenu li a:active {color:#0000FF;}  /* selected link */ 

Change the color as per your requirements in the color:#...;

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM