导航栏没有出现在我的页面顶部,出现在奇怪的地方

时间:2018-05-01 06:03:38

标签: html css

1 我试图用html和css创建一个模型谷歌网站练习我的技能,不幸的是我遇到了一个奇怪的问题,我的导航菜单出现在我的图像div中,尽管在此之前创建。我已经为navs和img容器添加了背景,以便于调试。感谢任何帮助人们真的很感激。我在jfiddle上发布了我的代码副本,我试图让蓝色元素(nav)在顶部,并且无法弄清楚为什么它们会在div中。

https://jsfiddle.net/thd2vh2b/1/4

感谢任何帮助,真的很感激。

<!DOCTYPE html>
<html>
<head>
<title> Google.ca </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>


nav {
padding:0;
margin:0;
background-color: blue;
}


div {
background-color:yellow;
text-align:center;
padding-top:100px;
padding-bottom: 75px;
margin: auto;


}



nav ul li{
display:inline;
display:inline;
margin-right: 

}

#nav1 {

float:left;
display:inline;


}


#nav2 {
float:right;
display:inline;
margin:8px;

}
footer li {

float: left;
margin:8px;
display:inline;
}

#rightbar li{
float:right;
}

</style>
</head>
<body>
<div id="top">
<nav id="nav1">
<ul style="list-style-type:none;">
<li> <a href="" >About</a></li>
<li> <a href="" >Store</a></li>
</ul>
</nav>
<nav id="nav2">
<ul style="list-style-type:none;">
<li> <a href="" >Gmail</a></li>
<li> <a href="" >Images</a></li>
<li> <a href="https://www.google.ca/intl/en/about/products/"><img src="gsquare.png" ></a></li>
<li><a href="https://support.google.com/accounts/answer/1714464"> <img src="gbell.png" ></a></li>
<li><a href="https://accounts.google.com/ServiceLogin/"><li> <img src="user.png" ></a></li>
</ul>
</nav>
</div>
<div>
<img src="logo.png";>
</div>
<footer id="rightbar";>
<ul style="list-style-type:none;">
<li><p>Privacy</p></li>
<li><p> Terms </p></li>
<li><p> Settings</p></li>
</ul>
</footer>
<footer>
<ul style="list-style-type:none;">
<li><p>Advertising</p></li>
<li><p> Business</p></li>
<li><p> Business</p></li>
</ul>
</footer>
</body>
</html>

Pic of problem

1 个答案:

答案 0 :(得分:0)

这是正确的吗?那是你想要的?

&#13;
&#13;
#divname {
background-color:yellow;
text-align:center;
padding-top:100px;
padding-bottom: 75px;
margin: auto;
}

div ul li{
display:inline;

margin-right: 10px;

}

#nav1 {



display:inline-block;
background-color:blue;


}


#nav2 {
float:right;
display:inline;
margin:8px;
background-color:blue;

}
footer li {

float: left;
margin:8px;
display:inline;

}

#rightbar li{
float:right;
}
&#13;
<html>
<head>
<title> Google.ca </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="StackQ.css"/>
</head>
<body>
<div id="nav1">
<ul style="list-style-type:none;">
<li> <a href="" >About</a></li>
<li> <a href="" >Store</a></li>
</ul>
</div>
<div id="divname">
<div id="top">

<div id="nav2">
<ul style="list-style-type:none;">
<li> <a href="" >Gmail</a></li>
<li> <a href="" >Images</a></li>
<li> <a href="https://www.google.ca/intl/en/about/products/"><img src="gsquare.png" /></a></li>
<li><a href="https://support.google.com/accounts/answer/1714464"> <img src="gbell.png"/></a></li>
<li><a href="https://accounts.google.com/ServiceLogin/"> <img src="user.png" /></a></li>
</ul>
</div>
</div>
<div id="a">
<img src="logo.png">
</div>
</div>
<footer id="rightbar">
<ul style="list-style-type:none;">
<li><p>Privacy</p></li>
<li><p> Terms </p></li>
<li><p> Settings</p></li>
</ul>
</footer>
<footer>
<ul style="list-style-type:none;">
<li><p>Advertising</p></li>
<li><p> Business</p></li>
<li><p> Business</p></li>
</ul>
</footer>

</body>
</html>
&#13;
&#13;
&#13;