0

CSS

body {
       background-color:#CCC
}

h1 {

    text-align: left;
    border-bottom:2px solid #03F margin-bottom:50px;
    border-bottom: 5px;
    border-bottom-color: #000;
    border-bottom-style: double;
    border-bottom-width: thick;
    font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
    font-size: 72px;
    font-style: normal;
    font-weight: bold;
    -moz-box-align: center;
}

.div1 {
    margin-width: 0px auto;
    -moz-box-align: center;
    -webkit-box-align: center;
    margin: center;
    margin-left: 150px;
    margin-right: 100px;
}

.div1 ul li {
    margin:auto;
    float: left;
    list-style-type: none;
}

.div1 ul li a {
    margin:auto;
    color: #FFF;
    text-decoration: none;
    background-color: #333;
    display: block;
    height: 50px;
    width: 220px;
    text-align: center;
    line-height: 50px;
    border-left-width: thin;
    border-left-style: solid;
    border-left-color: #CCC;
}

.noBorder {
    border-left-style: none !important;
}

.div1 ul li a:hover {
    background-color: #666;
}

.leftEdge {
    border-radius: 8px 0px 0px 8px;
}

.rightEdge {
    border-radius: 0px 8px 8px 0px;
}

.divide {
    padding: 10px 20px;
    background:SkyBlue;
    border: 1px solid #E5E5E5;
    -moz-box-shadow: rgba(200, 200, 200, 0.7) 0 4px 10px -1px;
    -webkit-box-shadow: rgba(200, 200, 200, 0.7) 0 4px 10px -1px;
    box-shadow: rgba(200, 200, 200, 0.7) 0 4px 10px -1px;
    margin-bottom: 20px;
    margin-left:100px;
    margin-right:250px;
    font-family:"Trebuchet MS", Helvetica, Arial, sans-serif;
    font-weight: bold;
    font-size: 16px;
    line-height: 100%;
    color: #000;
}

HTML

<h1>hEAD</h1>

<div class="div1">
    <ul>
        <li><a href="#" class="noBorder leftEdge">Item 1</a>
        </li>
        <li><a href="#">Item 2</a>
        </li>
        <li><a href="#">Item 3</a>
        </li>
        <li><a href="#" class="rightEdge">Item 4</a>
        </li>
    </ul>
</div>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<div class="divide" style="font-weight: normal !important;">Hey friends</div>

请任何人帮助我:我想让我的导航栏位于网页的中心。这是我的 html 和 CSS 文档: http:
//jsfiddle.net/dQbqP/
请帮助我,我真的需要解决方案。
尽快

4

2 回答 2

1

对 li 使用 text-align & display:inline-block: http://jsfiddle.net/dQbqP/1/

.div1 {
    margin:auto;
    text-align:center;
}
.div1 ul li {
    display:inline-block;
    list-style-type: none;
}
于 2013-06-08T13:00:25.187 回答
0

尝试这个...

body { background-color:#CCC }
.div1{
   text-align:centre;
     width:100%;
}

ul{
    width:35%;    
    display:block;
    margin:0 auto;
    padding:0px;
}

li{
    list-style:none;
    float:left;
    margin:0px;
    padding:10px;
    background-color: #333;    
}

a {
    color: #FFF;
    text-decoration: none;
}

li:hover { background-color: #666; }

li:first-child { border-radius: 8px 0px 0px 8px; }

li:last-child { border-radius: 0px 8px 8px 0px; }
于 2013-06-08T13:19:14.147 回答