自定义Bootstrap 3 Navbar - 对齐链接

时间:2014-02-25 02:09:00

标签: html5 css3 twitter-bootstrap-3

因此,在阅读了几个类似的问题和一些反复试验(主要是错误)后,我仍然试图解决这个问题。

我们创建的自定义导航栏上的链接是左对齐的。

|链接链接链接....................... | (所有左派都是合理的)

我们想要实现的是自定义导航栏中的均匀间距链接。

|链接....链接.....链接.....链接....链接| (它们如此均匀地展开。

包括css。不确定我哪里出错了,但任何帮助都会受到赞赏。

.navbar-custom {
  background-color: #4c8917;
  border-color: #3c6d12;
  background-image: -webkit-gradient(linear, left 0%, left 100%, from(#64b51e), to(#4c8917));
  background-image: -webkit-linear-gradient(top, #64b51e, 0%, #4c8917, 100%);
  background-image: -moz-linear-gradient(top, #64b51e 0%, #4c8917 100%);
  background-image: linear-gradient(to bottom, #64b51e 0%, #4c8917 100%);
  background-repeat: repeat-x;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff64b51e', endColorstr='#ff4c8917', GradientType=0);
}
.navbar-custom .navbar-brand {
  color: #ffffff;
}
.navbar-custom .navbar-brand:hover,
.navbar-custom .navbar-brand:focus {
  color: #e6e6e6;
  background-color: transparent;
}
.navbar-custom .navbar-text {
  color: #ffffff;
}
.navbar-custom .navbar-nav > li > a {
  color: #ffffff;
}
.navbar-custom .navbar-nav > li > a:hover,
.navbar-custom .navbar-nav > li > a:focus {
  color: #e6e6e6;
  background-color: transparent;
}
.navbar-custom .navbar-nav > .active > a,
.navbar-custom .navbar-nav > .active > a:hover,
.navbar-custom .navbar-nav > .active > a:focus {
  color: #e6e6e6;
  background-color: #3c6d12;
  background-image: -webkit-gradient(linear, left 0%, left 100%, from(#3c6d12), to(#54981a));
  background-image: -webkit-linear-gradient(top, #3c6d12, 0%, #54981a, 100%);
  background-image: -moz-linear-gradient(top, #3c6d12 0%, #54981a 100%);
  background-image: linear-gradient(to bottom, #3c6d12 0%, #54981a 100%);
  background-repeat: repeat-x;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3c6d12', endColorstr='#ff54981a', GradientType=0);
}
.navbar-custom .navbar-nav > .disabled > a,
.navbar-custom .navbar-nav > .disabled > a:hover,
.navbar-custom .navbar-nav > .disabled > a:focus {
  color: #cccccc;
  background-color: transparent;
}
.navbar-custom .navbar-toggle {
  border-color: #dddddd;
}
.navbar-custom .navbar-toggle:hover,
.navbar-custom .navbar-toggle:focus {
  background-color: #dddddd;
}
.navbar-custom .navbar-toggle .icon-bar {
  background-color: #cccccc;
}
.navbar-custom .navbar-collapse,
.navbar-custom .navbar-form {
  border-color: #3b6a12;
}
.navbar-custom .navbar-nav > .dropdown > a:hover .caret,
.navbar-custom .navbar-nav > .dropdown > a:focus .caret {
  border-top-color: #e6e6e6;
  border-bottom-color: #e6e6e6;
}
.navbar-custom .navbar-nav > .open > a,
.navbar-custom .navbar-nav > .open > a:hover,
.navbar-custom .navbar-nav > .open > a:focus {
  background-color: #3c6d12;
  color: #e6e6e6;
}
.navbar-custom .navbar-nav > .open > a .caret,
.navbar-custom .navbar-nav > .open > a:hover .caret,
.navbar-custom .navbar-nav > .open > a:focus .caret {
  border-top-color: #e6e6e6;
  border-bottom-color: #e6e6e6;
}
.navbar-custom .navbar-nav > .dropdown > a .caret {
  border-top-color: #ffffff;
  border-bottom-color: #ffffff;
}
@media (max-width: 767) {
  .navbar-custom .navbar-nav .open .dropdown-menu > li > a {
    color: #ffffff;
  }
  .navbar-custom .navbar-nav .open .dropdown-menu > li > a:hover,
  .navbar-custom .navbar-nav .open .dropdown-menu > li > a:focus {
    color: #e6e6e6;
    background-color: transparent;
  }
  .navbar-custom .navbar-nav .open .dropdown-menu > .active > a,
  .navbar-custom .navbar-nav .open .dropdown-menu > .active > a:hover,
  .navbar-custom .navbar-nav .open .dropdown-menu > .active > a:focus {
    color: #e6e6e6;
    background-color: #3c6d12;
  }
  .navbar-custom .navbar-nav .open .dropdown-menu > .disabled > a,
  .navbar-custom .navbar-nav .open .dropdown-menu > .disabled > a:hover,
  .navbar-custom .navbar-nav .open .dropdown-menu > .disabled > a:focus {
    color: #cccccc;
    background-color: transparent;
  }
}
.navbar-custom .navbar-link {
  color: #ffffff;
}
.navbar-custom .navbar-link:hover {
  color: #e6e6e6;
}

2 个答案:

答案 0 :(得分:0)

试试这个:

.navbar-custom .navbar-nav > li > a {
    margin-right: 50px;
}

使用间距播放,直到找到所需的间距。

答案 1 :(得分:0)

使用Less编译Bootstrap时,可以使用以下代码:

.nav.navbar-nav {
&:extend(.nav-justified all);
}