2015-06-21 20 views
0

這裏是CSS使用我想160像素移動在導航欄右邊的鏈接,但該

@import url(http://fonts.googleapis.com/css?family=Open+Sans:700); 
    #cssmenu { 
    background: #f96e5b; 
    width: auto; 
    } 
    #cssmenu > ul { 
    display:inline-block; 
    margin: 0 auto; 
    padding: 0; 
    line-height: 1; 
    text-align: 160px; 
    zoom: 1; 
    } 
    #cssmenu ul:after { 
    content: " "; 
    display: block; 
    font-size: 0; 
    height: 0; 
    clear: both; 
    visibility: hidden; 
    } 
    #cssmenu ul li { 
    display: inline-block; 
    padding: 0; 
    margin: 0; 
    } 
#cssmenu.align-right ul li { 
    float: right; 
} 
#cssmenu.align-center ul { 
    text-align: center; 
} 
#cssmenu ul li a { 
    color: #ffffff; 
    text-decoration: none; 
    display: block; 
    padding: 15px 25px; 
    font-family: 'Open Sans', sans-serif; 
    font-weight: 700; 
    text-transform: uppercase; 
    font-size: 14px; 
    position: relative; 
    -webkit-transition: color .25s; 
    -moz-transition: color .25s; 
    -ms-transition: color .25s; 
    -o-transition: color .25s; 
    transition: color .25s; 
} 
#cssmenu ul li a:hover { 
    color: #333333; 
} 
#cssmenu ul li a:hover:before { 
    width: 100%; 
} 
#cssmenu ul li a:after { 
    content: ""; 
    display: block; 
    position: absolute; 
    right: -3px; 
    top: 19px; 
    height: 6px; 
    width: 6px; 
    background: #ffffff; 
    opacity: .5; 
} 
#cssmenu ul li a:before { 
    content: ""; 
    display: block; 
    position: absolute; 
    left: 0; 
    bottom: 0; 
    height: 3px; 
    width: 0; 
    background: #333333; 
    -webkit-transition: width .25s; 
    -moz-transition: width .25s; 
    -ms-transition: width .25s; 
    -o-transition: width .25s; 
    transition: width .25s; 
} 
#cssmenu ul li.last > a:after, 
#cssmenu ul li:last-child > a:after { 
    display: none; 
} 
#cssmenu ul li.active a { 
    color: #333333; 
} 
#cssmenu ul li.active a:before { 
    width: 100%; 
} 
#cssmenu.align-right li.last > a:after, 
#cssmenu.align-right li:last-child > a:after { 
    display: block; 
} 
#cssmenu.align-right li:first-child a:after { 
    display: none; 
} 
@media screen and (max-width: 768px) { 
    #cssmenu ul li { 
    float: none; 
    display: block; 
    } 
    #cssmenu ul li a { 
    width: 100%; 
    -moz-box-sizing: border-box; 
    -webkit-box-sizing: border-box; 
    box-sizing: border-box; 
    border-bottom: 1px solid #fb998c; 
    } 
    #cssmenu ul li.last > a, 
    #cssmenu ul li:last-child > a { 
    border: 0; 
    } 
    #cssmenu ul li a:after { 
    display: none; 
    } 
    #cssmenu ul li a:before { 
    display: none; 
    } 
} 

我使用的HTML我不能這樣做是因爲初級講座

<div id='cssmenu'> 
<ul> 
    <li class='active'><a href='index.html'><span>Home</span></a></li> 
    <li><a href='#'><span>Products</span></a></li> 
    <li><a href='#'><span>About</span></a></li> 
    <li class='last'><a href='#'><span>Contact</span></a></li> 
</ul> 
</div> 

當我使用此代碼我的網站導航欄適用於全寬和導航欄上的鏈接在左端。我想要移動導航欄160px右側的鏈接。

我的網站http://logansdroids.com

回答

1

text-allign不取值爲px秒。

使用此:

#cssmenu > ul { 
    display: inline-block; 
    margin: 0 auto; 
    padding: 0; 
    line-height: 1; 
    margin-left: 160px; 
    zoom: 1; 
} 
+0

在我的博客上工作得很好謝謝你,如果我想使導航欄中心(未全寬),而不擴展它的左右。如果您需要示例,請查看主導航欄下方的博客導航欄http://www.shoutmeloud.com –

+0

向您添加'containernbt' NewContainer section元素。它的工作方式就像它沒有任何寬度,並且父容器默認情況下會給它'100%'寬度。 –