我是新來的HTML & CSS編碼,我試圖在我的導航欄中的項目居中問題。我已經嘗試了很多東西來中心項目,但我找不到解決方案。我認爲它與CSS(下面的代碼)中的.l-triangle-bottom
和.l-triangle-top
的border-style: solid;
有關,因爲當我刪除它時,所有項都移動到左側。如何集中導航欄項目?
有人可以幫我嗎?
這是我的代碼和一些解釋。
HTML
<div id="navigation_container">
<div class="l-triangle-top"></div>
<div class="l-triangle-bottom"></div>
<div class="rectangle">
<ul id="navigation">
<li class="active"><a href="#">✭ Home</a></li>
<li><a href="#">Location</a></li>
<li><a href="#">Location</a></li>
<li><a href="#">Our History</a></li>
<li><a href="#">Gifts</a></li>
<li><a href="#">Promotion</a></li>
<li><a href="#">Gallery</a></li>
</ul>
</div>
<div class="r-triangle-top"></div>
<div class="r-triangle-bottom"></div>
</div>
CSS
我有在頁面的頂部固定位置連接中心主容器。
#navigation_container {
position: fixed;
width: 1000px;
height: 200px;
top: 10%;
left: 50%;
margin-top: -100px;
margin-left: -500px;
}
然後我有一個矩形的主容器是項目所在。
.rectangle {
background: #e5592e;
height: 62px;
position: relative;
-moz-box-shadow: 0px 0px 4px rgba(0,0,0,0.55);
-webkit-box-shadow: 0px 0px 4px rgba(0,0,0,0.55);
box-shadow: 0px 0px 4px rgba(0,0,0,0.55);
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
z-index: 500;
margin: 3em 0;
text-align: center;
}
而這些都是項目。
#navigation li {
list-style: none;
display: block;
float: left;
margin: 0.1em 0.8em;
}
#navigation li a {
text-shadow: 0 2px 1px rgba(0,0,0,0.5);
display: block;
text-decoration: none;
color: #f0f0f0;
font-size: 1.6em;
line-height: 60px;
}
#navigation li.active a:hover, #navigation li a:hover {
margin-top: 2px;
color: aqua;
}
而且我在矩形的每個站點都有一些三角形來製作磁帶的效果。
.l-triangle-top {
border-color: #d9542b transparent transparent;
border-style: solid;
border-width:50px;
height:0px;
width:0px;
position: relative;
float: left;
top: 52px;
left: -50px;
}
.l-triangle-bottom {
border-color: transparent transparent #d9542b;
border-style:solid;
border-width:50px;
height:0px;
width:0px;
position: relative;
float: left;
top: 10px;
left: -150px;
}
.r-triangle-top {
border-color: #d9542b transparent transparent;
border-style:solid;
border-width:50px;
height:0px;
width:0px;
position: relative;
float: right;
right: -45px;
top: -107px;
}
.r-triangle-bottom {
border-color: transparent transparent #d9542b;
border-style:solid;
border-width:50px;
height:0px;
width:0px;
position: relative;
float: right;
top: -149px;
right: -145px;
}