我无法理解为什么浏览器不允许我在DIV上设置一个边距顶或填充顶,以允许我对文本进行居中。
HTML -
<div id="header">
<div id="Nav">
<div id="navright">
<a href="#">Home</a>
<a href="#">About Us</a>
<a href="#">Contact Us</a>
<a href="#">Find Us</a>
</div>
</div>
</div>CSS -
#nav {
width: auto;
position: relative;
}
#nav a {
margin-left: 5px;
margin-right: 5px;
text-decoration: none;
font-family: "Arial";
font-size: 14pt;
color: #ffffff;
position: relative;
margin-top: 10px;
}结果-

你知道我哪里出错了吗?谢谢
发布于 2013-09-23 11:00:05
你在写Nav nog nav
Html代码应该是:
<div id="nav">而非<div id="Nav">
这就是为什么你的css不能在div上工作的原因
并将line-height用于a
#nav a {
line-height: (pixel height of the li or nav);
}Working JsFiddle here
发布于 2013-09-23 11:03:08
尝试在链接中添加display:inline-block;
#nav a {
...
display:inline-block;
}并将<div id="Nav">重命名为<div id="nav">
发布于 2013-09-23 11:00:57
将display: inline-block;添加到标记中
演示
很明显地把你的错误更正为导航。
https://stackoverflow.com/questions/18957508
复制相似问题