导航,导航菜单下的白线,活动链接

时间:2014-10-10 09:05:22

标签: css twitter-bootstrap asp.net-mvc-4 visual-studio-2012

我有这个:_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>

这是我的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;

    }
}

如何在菜单栏中的活动链接下创建白线?我使用Active:IsActive进行了攻击,但是如何在活动链接下创建白线。

谢谢

我现在就这样:

 <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>

并且这适用于网站:

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

        }

但是现在所有项目都有白色条纹,而不是单独的活动链接。

如果我使用它:

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

然后所有项目都有红线

如果我这样做:

  <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>

仍然突出显示两个项目

1 个答案:

答案 0 :(得分:5)

可能的解决方案

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

'<active-class>'替换为您正在使用的班级名称。 f.i. class name =活跃于li.active > a

有关带有红色下划线的示例(红色以查看结果),请参阅JSFiddle