bootstrap, white line under navigation menu, active link

10,868

A possible solution

li.<active-class> > a {
   border-bottom:1px solid white;
}

Replace '<active-class>' with the class name you are using. f.i. class name = active than it would be li.active > a

See JSFiddle for an example with a red underline (red to see the result)

Share:
10,868
Niels Savant
Author by

Niels Savant

I am working with C#,vb.net, C, Java, mvc, web forms,jquery, bootstrap, Kendo, SQl2012

Updated on June 05, 2022

Comments

  • Niels Savant
    Niels Savant almost 2 years

    I have this: _Layout.cshtml

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>@ViewBag.Title - LolaBikeMen</title>
        @Styles.Render("~/Content/css")
        @Scripts.Render("~/bundles/modernizr")
    </head>
    <body>
    
    
    
        <div class="navbar navbar-inverse navbar-fixed-top">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
    
    
    
                    @Html.ActionLink("LolaBikeMen", "Index", "Home", null, new { @class = "navbar-brand" })
                </div>
                <div class="navbar-collapse collapse">
                    <br />
                    <div class="float-right">
                        @*<section id="login">
                            @Html.Partial("_LoginPartial")
                        </section>*@
    
                        <ul class="nav navbar-nav">
                            @*<li>@Html.ActionLink("Home", "Index", "Home")</li>*@
                            <li @if (@ViewContext.RouteData.GetRequiredString("controller") == "Account") { @Html.AttributeEncode("class=active")  ; }>
                                @Html.ActionLink("WHO", "Index", "Account")
                            </li>
                            <li class="{active:isActive}">@Html.ActionLink("WHAT", "Index", "Student")</li>
                            <li class="nav">@Html.ActionLink("AGENDA", "Index", "Course")</li>
                            <li class="nav">@Html.ActionLink("PHILOSPY", "Index", "Instructor")</li>
                            <li class="nav">@Html.ActionLink("BUCKET-LIST", "Index", "Department")</li>
                            <li class="nav">@Html.ActionLink("LolaRiders", "Index", "LolaBiker")</li>
                            <li class="nav">@Html.ActionLink("bycicle", "Index", "Bycicle")</li>
    
                            <li class="nav"> @Html.Partial("_LoginPartial")</li>
    
                        </ul>
                    </div>
                </div>
    
    
            </div>
        </div>
        <div class="container body-content">
            @RenderBody()
            <hr />
            <footer>
                <p>&copy; @DateTime.Now.Year - LolaBikeMen</p>
            </footer>
        </div>
    
        @Scripts.Render("~/bundles/jquery")
        @Scripts.Render("~/bundles/bootstrap")
        @RenderSection("scripts", required: false)
    </body>
    </html>
    

    and this is my site.css:

    /* Move down content because we have a fixed navbar that is 50px tall */
    .container{
        /*background-color:MenuText;*/
    }
    .container2{
    
        width:100%;
        height:100%;
    }
    
    label
    {
        color:white;
    
    }
    
    .add-on .input-group-btn > .btn {
      border-left-width:0;left:-2px;
      -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
      box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
    }
    /* stop the glowing blue shadow */
    .add-on .form-control:focus {
     box-shadow:none;
     -webkit-box-shadow:none; 
     border-color:#cccccc; 
    }
    
    body {
    
        margin-top:90px;
    
    
        /*padding-top: 90px;
        padding-bottom: 20px;*/
    
    }
    
    /*html {
                background: url(~/Images/Large.JPG) no-repeat center center fixed;
                -webkit-background-size: cover;
                -moz-background-size: cover;
                -o-background-size: cover;
                background-size: cover;
            }*/
    
    .wrapper {
      background-image: url(../Images/Large.JPG);
      background-repeat: no-repeat;
      background-size: 100% 100%;
      width: 100%;
      height: 100%;
    
    }
    .wide {
      width:100%;
      height:1000px;
      background-image:url('../Images/Large.JPG');
      background-size:cover;
    }
    
    .wide img {
      width:100%;
    }
    
    navbar{
        color:white;
    }
    
    .table-striped>tr>td:nth-child(odd)>td, 
    .table-striped>tr>td:nth-child(odd)>td {
        background-color:white;
    }
    
    .table.table-condensed tr th {
       border-top: 1px solid white; 
    }
    
    .table.table-condensed tr th {
       border-bottom: 1px solid white; 
    }
    
    .a:hover, a:focus {
            color:floralwhite;
            text-decoration: underline;
        }
    
    a {
        color:floralwhite;
        text-decoration: none;
    }
    
    .table.table-condensed tr td {
       border-bottom: 1px solid white; /* Change the color you want to set */
    }
    
    .wrapper {
        width: 100%;
        background-color: lightcyan;
    }
    
    img {
        background-image: url('../Images/Large.JPG');
        background-repeat: no-repeat;
        background-position:top;
        background-size:cover;
        width: 100%;
        height: 100%;
    }
    
    /**/
    #map {
            height: 100%;
            width: 100%;
    }
    
    #map img {
            max-width: 100%;
    }
    
    html, body {
            height: 100%;
            width: 100%;
    }
    
    .hallo{
         background-image: url('../Images/Large.JPG');
    
    
    }
    
    .fullscreen,
    .content-a {
        width:100%;
        min-height:100%;
    }
    
    
    .background {
        background-image: url('../Images/Large.JPG');
        background-repeat: no-repeat;
        background-attachment: fixed;
        background-size: 100%;
    
    }
    
    .fill {
        top: -10px;
        left: 0;
        right: 0;
        bottom: 0;
        position:relative;
        /*overflow-x;*/
        width:100%;
        height:100%;
    }
    
    html,body{height:100%;}
    .carousel,.item,.active{height:100%;}
    .carousel-inner{height:100%;}
    .fill{width:100%;height:100%;background-position:center;background-size:cover;}
    
    .navbar {
            margin-bottom: 0;
    }
    
    /* Demo */
    #map { background:black; }
    
    
    
    
    /**/
    
    /* Wrapping element 
    /* Set some basic padding to keep content from hitting the edges */
    .body-content {
        padding-left: 15px;
        padding-right: 15px;
    
    
    }
    
    /* Override the default bootstrap behavior where horizontal description lists 
       will truncate terms that are too long to fit in the left column 
    */
    .dl-horizontal dt {
        white-space: normal;
    }
    
    /* Set widths on the form inputs since otherwise they're 100% wide */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="tel"],
    input[type="select"] {
        max-width: 280px;
    }
    
    /* Responsive: Portrait tablets and up */
    @media screen and (min-width: 768px) {
        .jumbotron {
            margin-top: 20px;
        }
        .body-content {
            padding: 0;
    
        }
    }
    

    How to make a white line under the active link in the menu bar? I triied with Active:IsActive, but how to make the white line under the active link.

    Thank you

    I have it now like this:

     <ul class="nav navbar-nav">
    
                            <li class=" nav active">@Html.ActionLink("WHO", "Index", "Account")</li>
                            <li class=" nav active">@Html.ActionLink("WHAT", "Index", "Student")</li>
                            <li class=" nav active">@Html.ActionLink("AGENDA", "Index", "Course")</li>
                            <li class=" nav active">@Html.ActionLink("PHILOSPY", "Index", "Instructor")</li>
                            <li class="nav active">@Html.ActionLink("BUCKET-LIST", "Index", "Department")</li>
                            <li class="nav active">@Html.ActionLink("LolaRiders", "Index", "LolaBiker")</li>
                            <li class="nav active">@Html.ActionLink("bycicle", "Index", "Bycicle")</li>
    
                            <li class="nav"> @Html.Partial("_LoginPartial")</li>
    
                        </ul>
    

    and this for site:

    .active {
                font-style:oblique ;
                 border-bottom:1px solid white;
    
            }
    

    But now all the items have a white stripe, and not onely the active link.

    If I use this:

    li.active > a {
        border-bottom:1px solid red;
    }
    

    then also all the items have red line

    and if I just do this:

      <ul class="nav navbar-nav">
    
                            <li @if (@ViewContext.RouteData.GetRequiredString("controller") == "Account") { @Html.AttributeEncode("class=active")   ; }>
                                @Html.ActionLink("WHO", "Index", "Account")
                            </li>
    
                            <li @if (@ViewContext.RouteData.GetRequiredString("controller") == "Student") { @Html.AttributeEncode("class=active")    ; }>
                                @Html.ActionLink("What", "Index", "Student")
                            </li>
    
    
                            <li class="nav"> @Html.Partial("_LoginPartial")</li>
    
                        </ul>
    

    still both items are highlighted