gpt4 book ai didi

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

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

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

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