【发布时间】:2014-04-02 09:42:17
【问题描述】:
在这里,我设置了一个带有居中徽标的导航栏。唯一的问题是我无法让它看起来与间距完全正确。徽标设置为“位置:绝对”“左:50%”和“左边缘:-125px”,因此始终位于中心。现在我只需要以更对称的方式使文本在其周围保持平衡,但我似乎无法弄清楚如何做到这一点。
这是 HTML
<link rel="stylesheet" href="stylesheet.css"/>
</head>
<body>
<div class="header">
<div class="nav">
<ul>
<li class="navright"><a href="#">HOME</a></li>
<li class="navright"><a href="#">MENU</a></li>
<li id="logo"><a href="#"><img src="Images/pantry logo.png" width="536" height="348"/></a></li>
<li class="navleft"><a href="#">CONTACT</a></li>
<li class="navleft"><a href="#">ABOUT</a></li>
</ul>
</div>
</div><!--end header-->
还有 CSS。
.header {
width: 960px;
height: 200px;
margin: 0 auto;
text-align: center;
position: relative;
}
div ul li {
display: inline-block;
padding: 105px 70px 40px 0;
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 18px;
color: #4f4d4b;
text-decoration: none;
list-style: none;
}
div ul li a {
list-style: none;
text-decoration: none;
color: #4f4d4b;
}
.nav ul li a:visited {
text-decoration: none;
color: #4f4d4b;
}
#logo a img {
width: 250px;
height: auto;
position: absolute;
left: 50%;
margin-left: -125px;
display: inline-block;
}
#logo {
height: 60px;
padding-top: 40px;
width: 250px;
}
你可以去网站here.
【问题讨论】:
标签: html css positioning nav spacing