目前页面顶部与导航栏之间存在差距。最初它是固定的,没有间隙。然而,当我解开它时,它增加了差距。 body和html的边距和填充都设置为零。
html{
font-family: abel;
background-color: #a4bdd1
}
body{
overflow-x:hidden;
}
nav {
text-align: center;
background-color: #e4e6e5;
position: fixed;
top: 0;
left: 0;
z-index: 9999;
width: 100%;
border-bottom: solid #05182e 2px;
}
nav li {
display: inline-block;
font-size: 35px;
padding: 15px;
font-weight: bold;
vertical-align: middle;
}
nav a{
border: solid black 2px ;
border-radius: 25%;
padding: 2px;
background-color: #cccccc;
color: #1f3b5a;
text-decoration: none;
font-size: 30px;
transition: all 0.5s ease-in-out;
}
nav a:hover{
font-size: 40px;
transition: all 0.5s ease-in-out;
}
nav img{
width: 30%;
border: none;
transition: all 0.5s ease-in-out;
}
nav img:hover{
width: 40%;
transition: all 0.5s ease-in-out;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style2.css">
<link href='https://fonts.googleapis.com/css?family=Abel' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Bitter:700' rel='stylesheet' type='text/css'>
<link rel="icon" type="image/png" href="favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="favicon-16x16.png" sizes="16x16" />
<title>Brampton Thunder Roster</title>
</head>
<body>
<nav>
<ul>
<li/><img src="images/logo.png" alt="Canadian Women's Hockey League Logo"></li>
<li> <a href="index.html" target="_blank">Home</a></li>
<li> <a href="roster.html" target="_blank">Roster</a></li>
<li> <a href="schedule.html" target="_blank">Schedule</a></li>
<li><a href="http://cwhl.ca" target="_blank"><img src="images/cwhllogo.png"></a></li>
</ul>
</nav>
答案 0 :(得分:1)
它导致问题的<ul>
元素的上边距。此外,您的第一个打开<li>
代码需要删除斜杠:<li/>
错误。
<nav>
<ul>
<li/><img src="images/logo.png" alt="Canadian Women's Hockey League Logo"></li>
<li> <a href="index.html" target="_blank">Home</a></li>
<li> <a href="roster.html" target="_blank">Roster</a></li>
<li> <a href="schedule.html" target="_blank">Schedule</a></li>
<li><a href="http://cwhl.ca" target="_blank"><img src="images/cwhllogo.png"></a></li>
</ul>
</nav>
通过添加以下内容进行修复:
CSS:
ul {
margin: 0;
}