如何使Bootstrap导航栏品牌形象更大

时间:2016-11-02 21:14:58

标签: html css html5 twitter-bootstrap css3

我在尝试增加主导航内部导航栏品牌形象的大小时遇到​​了一些问题。看起来它不会更大50px。我希望它大约100px高,但似乎无法解决如何做到这一点。我目前将它放在导航中心,旁边有汉堡菜单。

有人知道如何实现我想做的事吗?

HTML:

 .navbar-brand {
    background: url(../img/logo.png);
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    width: 300px;
    transform: translateX(-50%);
    left: 50%;
    position: absolute;
    padding: 0;
  }

.navbar-default .navbar-toggle .icon-bar {
  background-color: #fff;
}

.navbar .navbar-nav {
  display: inline-block;
  float: none;
  vertical-align: top;
}

.navbar .navbar-collapse {
  text-align: center;
}

.custom-nav {
  color: #fff;
  background: #718373;
  border-radius: 0;
  margin-bottom: 0;
  border: 0;
}

.custom-nav .navbar-nav>li>a {
  color: #fff;
  margin: 0 auto;
}

.custom-nav .navbar-nav>li>a:hover,
.custom-nav .navbar-nav>li>a:focus {
  color: #fff;
}

.navbar-default .navbar-toggle:focus,
.navbar-default .navbar-toggle:hover {
  background: none;
}

.custom-nav .navbar-nav>.open>a,
.custom-nav .navbar-nav>.open>a:focus,
.custom-nav .navbar-nav>.open>a:hover {
  color: #fff;
  background: none;
}

.custom-nav .navbar-nav li {
  margin: 0 auto;
  text-align: center;
  width: 150px;
}

.dropdown-menu {
  padding: 0;
  margin: 0;
  background: #718373;
  border: none;
  box-shadow: none;
  min-width: 90px;
}

.dropdown-menu li:last-child a {
  margin-bottom: 10px;
}

.dropdown-menu>li>a {
  display: block;
  clear: both;
  font-weight: normal;
  color: #fff;
  width: 95%;
  margin: 0 auto;
  text-align: center;
  padding: 20px 0;
}

.dropdown-menu>li>a:focus,
.dropdown-menu>li>a:hover {
  color: #fff;
  text-decoration: none;
  background: none;
  outline: 2px solid white;
  outline-offset: -2px;
}

CSS:

.navbar-header .navbar-brand {
  height: 100px;
}

这就是目前的看法

Logo image

添加

后编辑
{{1}}

new logo image

1 个答案:

答案 0 :(得分:4)

Bootstraps导航栏样式会覆盖您的样式。使用higher specificity将您的样式应用于导航栏品牌,例如与

.navbar-header .navbar-brand {
  height: 100px;
}

这样你可以覆盖身高。



.navbar-header .navbar-brand {
  background: url(../img/logo.png);
  background: url(//placehold.it/300x100);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  height: 100px;
  width: 300px;
  transform: translateX(-50%);
  left: 50%;
  position: absolute;
  padding: 0;
  : #fff;
}
.navbar .navbar-nav {
  display: inline-block;
  float: none;
  vertical-align: top;
}
.navbar .navbar-collapse {
  text-align: center;
}
.custom-nav {
  color: #fff;
  background: #718373;
  border-radius: 0;
  margin-bottom: 0;
  border: 0;
}
.custom-nav .navbar-nav>li>a {
  color: #fff;
  margin: 0 auto;
}
.custom-nav .navbar-nav>li>a:hover,
.custom-nav .navbar-nav>li>a:focus {
  color: #fff;
}
.navbar-default .navbar-toggle:focus,
.navbar-default .navbar-toggle:hover {
  background: none;
}
.custom-nav .navbar-nav>.open>a,
.custom-nav .navbar-nav>.open>a:focus,
.custom-nav .navbar-nav>.open>a:hover {
  color: #fff;
  background: none;
}
.custom-nav .navbar-nav li {
  margin: 0 auto;
  text-align: center;
  width: 150px;
}
.dropdown-menu {
  padding: 0;
  margin: 0;
  background: #718373;
  border: none;
  box-shadow: none;
  min-width: 90px;
}
.dropdown-menu li:last-child a {
  margin-bottom: 10px;
}
.dropdown-menu>li>a {
  display: block;
  clear: both;
  font-weight: normal;
  color: #fff;
  width: 95%;
  margin: 0 auto;
  text-align: center;
  padding: 20px 0;
}
.dropdown-menu>li>a:focus,
.dropdown-menu>li>a:hover {
  color: #fff;
  text-decoration: none;
  background: none;
  outline: 2px solid white;
  outline-offset: -2px;
}

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default custom-nav">
  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#"></a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">History</a>
            </li>
            <li><a href="team.php">Meet The Team</a>
            </li>
            <li><a href="#">Facilities</a>
            </li>
            <li><a href="#">Opening Times</a>
            </li>
            <li><a href="membership.php">Membership</a>
            </li>
          </ul>
        </li>
        <li><a href="#">Diary</a>
        </li>
        <li><a href="lessons.php">Lessons</a>
        </li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> Events<span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="corporate.php">Corporate Days </a>
            </li>
            <li><a href="hens_stags.php">Hens & Stags</a>
            </li>
            <li><a href="#">Group Bookings</a>
            </li>
          </ul>
        </li>
        <li><a href="#">Gallary</a>
        </li>
        <li><a href="contact.php">Contact</a>
      </ul>
    </div>
    <!-- /.navbar-collapse -->
  </div>
  <!-- /.container-fluid -->
</nav>
&#13;
&#13;
&#13;