gpt4 book ai didi

html - 如何使导航菜单居中

转载 作者:太空宇宙 更新时间:2023-11-04 14:55:44 27 4
gpt4 key购买 nike

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/
请帮助我,我真的需要解决方案。
尽快

最佳答案

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

.div1 {
margin:auto;
text-align:center;
}
.div1 ul li {
display:inline-block;
list-style-type: none;
}

关于html - 如何使导航菜单居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16999689/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com