如何将导航栏大小固定为其原始大小

how to fix navbar size to its original

我正在尝试制作一个带有下拉菜单的导航栏。当我添加下拉菜单时,我的导航栏的高度变大了,虽然我评论了下拉菜单代码,但导航栏的大小并没有达到它的原始大小。怎么恢复原来的尺寸。 这是我的 html 代码。

<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">span1</span>
                <span class="icon-bar">span2</span>
                <span class="icon-bar">span3</span>
            </button>
            @Html.ActionLink("E-HealthCare", "Index", "Home", new { area = "" }, new { @class = "navbar-brand shadow" })
        </div>
        <div class="navbar-collapse collapse">
            <ul class="nav navbar-nav">
                <li class="text-position-li-nav">@Html.ActionLink("Home", "Index", "Home")</li>
                @*<li>@Html.ActionLink("About", "About", "Home")</li>
        <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
        <li>@Html.DropDownList("Services","ALL")</li>*@

                @* <li class="dropdown-Nav">
            <button class="dropbtn">
                Salesman
                <span class="glyphicon glyphicon-alert"></span>
            </button>
            <div class="dropdown-content">
                <a href="#">1111</a>
                <a href="#">2222</a>
            </div>
        </li>*@
            </ul>
            @** <div class="dropdown">
                        <button class="dropbtn">
                            Services
                            <span class="glyphicon glyphicon-chevron-down"></span>
                        </button>
                        <div class="dropdown-content">
                            <a href="#">service1</a>
                            <a href="#">service2</a>
                            <a href="#">service3</a>
                        </div>

                    </div>*@
                    <ul class="nav navbar-nav navbar-right">
                        <li><a href="@Url.Action("SignUp","Account")"><Span class="glyphicon glyphicon-user"></Span> Sign Up </a></li>

                        <li><a href="@Url.Action("Login","Account")"><Span class="glyphicon glyphicon-log-in"></Span> Login </a></li>
                    </ul>
                </div>

        </div>
        </div>

这是 CSS 代码。

.navbar {
  font-size: 1.25em;
}

.navbar-inverse {
  background-color: #089136;
}

  .navbar-inverse .navbar-brand {
      color: deepskyblue;
      font-family: 'Brush Script MT';
      font-size: 1.50em;
      font-weight: 400;
      text-shadow: 5px 5px 5px black;
  }

  .navbar-inverse .navbar-nav > li > a {
      color: black;
  }

.navbar-inverse .navbar-nav > li > a:hover, .dropdown:hover .dropbtn {
  background-color: #056124;
}

.text-position-li-nav {
  padding: 14px 16px;
}


.glyph-pad {
  padding-top: 2px;
}

.dropdown-Nav  {
  float: left;
  overflow: hidden;
}

  .dropdown .dropbtn {
      font-size: 16px;
      border: none;
      outline: none;
      color: black;
      padding: 2px 0px 0px 0px;
      background-color: inherit;
      font-family: inherit; /* Important for vertical align on mobile phones */
      margin: 0
  }

.dropdown-content {
  visibility: hidden;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 1;
}

  .dropdown-content a {
      float: none;
      color: black;
      padding: 12px 16px;
      text-decoration: none;
      display: block;
      text-align: left;
  }

      .dropdown-content a:hover {
          background-color: #ddd;
      }

帮我解决这个也请告诉我为什么会这样。谢谢。

尝试删除 CSS 中 li 的填充。这个....

.text-position-li-nav {
  padding: 14px 16px;
}

或者只删除垂直边距

.text-position-li-nav {
  padding: 0 16px;
}