html - 导航栏中未对齐的元素

标签 html css

我正在创建一个网站,目前正在处理主导航栏。看起来我在排列元素时遇到了麻烦。在我在右上角添加汉堡菜单图标之前,它基本上工作正常。 Screenshot

我猜它与打开 float 有关,以便将 Logo 和汉堡包图标放在页面边缘,同时保持链接完好无损。

这是导航栏的源代码。 (PHP 执行后。)

    <html lang="en">
<head>
    <meta charset="utf-8">
    <title>Alexworks</title>
    <link rel="stylesheet" type="text/css" href="/resources/CSS/main.css" media="screen" />
<body><nav  id="navigation">
    <ul>
        <li id="logo"><a href="http://alexandstein.com/">Alexworks</a></li>
        <li><a href="http://alexandstein.com/main/about">About</a></li>
        <li><a href="http://alexandstein.com/main/projects">Projects</a></li>
        <li><a href="http://alexandstein.com/main/meta">Meta</a></li>
        <li id="hamburger"><img src="http://alexandstein.com/resources/images/icons/hamburger.png" alt="Menu" class="iconSmall"/>        </li>
    </ul>
</nav><div id="content">

这是与导航栏相关的 CSS。

    body{
    font-family: helvetica;
    font-size: 1.1em;
    margin: 0%;
    padding-top: 0%;
}

#navigation{
    list-style-type: none;
    text-align: center;
    width: 100%;
    margin: 0%;
    padding: 0%;

    background-color: black;
    height: 2em;
}
#navigation ul{
    margin: 0%;
    padding: 0%;
    padding-top: 0%;
}
#navigation a{
    color: #aaa;
}
#navigation a:visited{
    color: #999;
}
#navigation a:hover{
    color: #bbb;
}
#navigation li{
    display: inline-block;
    width: 15em;
    height: 1.8em;

    border-bottom-style: solid;
    border-bottom-color: red;
}
#navigation li:hover{
    background-color: #333;
}
#navigation .iconSmall{
    width: 30px;
    height:30px;
}
#navigation #logo{
    display: inline-block;
    text-align: left;
    width: inherit;
    float:left;
    letter-spacing: 5px;
}
#navigation #links{
    display: inline-block;
}
#navigation #hamburger{
    width: 30px;
    border-bottom-style: none
    float: right;
}

a{
    text-decoration: none;
}

请原谅任何困惑的代码。我习惯于编程而不是超文本和样式表。

最佳答案

问题是在 border-bottom-style: none 之后您的 CSS 中缺少 ; 分号

修复:

#navigation #hamburger{
    width: 30px;
    border-bottom-style: none;
    float: right;
}

演示:http://jsfiddle.net/pratik136/yCV6D/

关于html - 导航栏中未对齐的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17914212/

相关文章:

javascript - 温泉 : create right to left slide button

javascript - 如何根据图片点击打开局部 View ?

javascript - 基于Tab切换的页面刷新

javascript - 如何更改 Chart.JS 中标签的字体(系列)?

javascript - 单击按钮,向 div 添加一些文本和数字。不起作用

html - 居中工具提示?

php - 如何从wordpress菜单中获取单个特定项目

css - 通过 css 更改链接悬停颜色

javascript - 为什么 jQuery .attr 总是说这是未定义的?

html - 防止 IE 上的下拉选择选项