文本

2017-10-15 38 views
0

嗨由於某種原因,我似乎無法allign我的境界我有我的導航欄用我的文字都對齊邊框:您可以在小提琴Here文本

每次我嘗試和margin-top邊境看到它將一切都移動下來導航欄文本它的自我是在我的網頁在正確的地方,我只是想實際邊界線向下移動到與文本的位置對準

body { 
 
    font-family: 'Open Sans', sans-serif, Arial; 
 
    font-size: 16px; 
 
    color: #6D6D6D; 
 
    background-color: black; 
 
    font-weight: 300; 
 
} 
 

 
.navbar-default { 
 
    background-color: transparent; 
 
    border-top: 0px solid rgba(0, 0, 0, 0.5); 
 
    border-bottom: 0px solid rgba(0, 0, 0, 0.5); 
 
    border-left: 0px solid rgba(0, 0, 0, 0.5); 
 
    border-right: 0px solid rgba(0, 0, 0, 0.5); 
 
    -webkit-transition: background-color 200ms linear; 
 
    -moz-transition: background-color 200ms linear; 
 
    -o-transition: background-color 200ms linear; 
 
    -ms-transition: background-color 200ms linear; 
 
    transition: background-color 200ms linear; 
 
    padding-top: 9px; 
 
    padding-bottom: 20px; 
 
} 
 

 
.navbar.navbar-default .navbar-collapse { 
 
    border: 0; 
 
    -webkit-box-shadow: none; 
 
    box-shadow: none; 
 
} 
 

 
.navbar-nav>li { 
 
    border-right: 1px solid white; 
 
    height: 20px; 
 
    padding-left: 28px; 
 
    padding-top: 25px; 
 
} 
 

 
.navbar-nav>li:last-child { 
 
    border: none; 
 
} 
 

 
.navbar-default .navbar-toggle { 
 
    border-color: rgba(0, 0, 0, 0); 
 
} 
 

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

 
.navbar-toggle { 
 
    margin-top: 19px; 
 
    margin-right: 43px; 
 
} 
 

 
.navbar-default .navbar-nav>li>a { 
 
    color: white; 
 
    font-size: 15px; 
 
    line-height: 1px; 
 
} 
 

 
.navbar-default .navbar-nav>li>a:hover, 
 
.navbar-default .navbar-nav>li>a:focus { 
 
    background-color: #FFC600; 
 
    text-decoration: none; 
 
    color: #ffffff; 
 
    -webkit-transition: background-color 200ms linear; 
 
    -moz-transition: background-color 200ms linear; 
 
    -o-transition: background-color 200ms linear; 
 
    -ms-transition: background-color 200ms linear; 
 
    transition: background-color 200ms linear; 
 
}
<nav class="navbar navbar-default navbar-fixed-top"> 
 
    <div class="container"> 
 
    <div class="navbar-header"> 
 
     <button class="navbar-toggle" data-target="#myNavbar" data-toggle="collapse" type="button"> 
 
\t \t \t \t \t <span class="icon-bar"></span> <span class="icon-bar"></span> 
 
\t \t \t \t \t <span class="icon-bar"></span> 
 
\t \t \t \t \t </button> 
 
     <a class="navbar-brand"><img alt="" src="Images/logo.png" class="img-responsive"></a> 
 
    </div> 
 
    <div class="collapse navbar-collapse" id="myNavbar"> 
 
     <ul class="nav navbar-nav navbar-right"> 
 
     <li> 
 
      <a href="#">Home</a> 
 
     </li> 
 
     <li> 
 
      <a href="#">About Us</a> 
 
     </li> 
 
     <li> 
 
      <a href="#">Services</a> 
 
     </li> 
 
     <li> 
 
      <a href="#">Contact Us</a> 
 
     </li> 
 
     </ul> 
 
    </div> 
 
    </div> 
 
</nav>

回答

3

請更正下面的CSS它看起來更好,請讓我知道如果您有任何問題,此修復程序。

.navbar-nav>li { 
    border-right: 1px solid white; 
    padding-left: 14px; 
    padding-right: 14px; 
    height: 100%; 
} 

JSFiddle Demo

+0

其實不用擔心,完美的作品,感謝XX – RonTheOld

+0

@RonTheOld不客氣! –

2

你忘了a

.navbar-nav>li a { // ... 
.navbar-nav>li:last-child a { // ... 

取出填充物,只是離開它,因爲它是以前。 fiddle

1

我注意到你在.navbar-nav>li上有一個填充是導致這個問題的原因。

下面是更新後的CSS:

body { 
    font-family: 'Open Sans', sans-serif, Arial; 
    font-size: 16px; 
    color: #6D6D6D; 
    background-color: black; 
    font-weight: 300; 
} 



.navbar-default { 
    background-color: transparent; 
    border-top: 0px solid rgba(0, 0, 0, 0.5); 
    border-bottom: 0px solid rgba(0, 0, 0, 0.5); 
    border-left: 0px solid rgba(0, 0, 0, 0.5); 
    border-right: 0px solid rgba(0, 0, 0, 0.5); 
    -webkit-transition: background-color 200ms linear; 
    -moz-transition: background-color 200ms linear; 
    -o-transition: background-color 200ms linear; 
    -ms-transition: background-color 200ms linear; 
    transition: background-color 200ms linear; 
    padding-top: 9px; 
    padding-bottom: 20px; 
} 

.navbar.navbar-default .navbar-collapse { 
    border: 0; 
    -webkit-box-shadow: none; 
    box-shadow: none; 
} 

.navbar-nav>li { 
     border-right: 1px solid white; 
    height: 30px; 
    text-align:center; 
} 

.navbar-nav>li:last-child{ 
    border: none; 
} 
.navbar-default .navbar-toggle { 
    border-color: rgba(0, 0, 0, 0); 
} 

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


.navbar-toggle { 
    margin-top: 19px; 
    margin-right: 43px; 
} 

.navbar-default .navbar-nav>li>a { 
    color: white; 
    font-size: 15px; 
    line-height: 1px; 
} 

.navbar-default .navbar-nav>li>a:hover, .navbar-default .navbar-nav>li>a:focus { 
    background-color: #FFC600; 
    text-decoration: none; 
    color: #ffffff; 
    -webkit-transition: background-color 200ms linear; 
    -moz-transition: background-color 200ms linear; 
    -o-transition: background-color 200ms linear; 
    -ms-transition: background-color 200ms linear; 
    transition: background-color 200ms linear; 
} 

和工作環節:https://jsfiddle.net/DTcHh/38351/