似乎有一个简单的解决方法,但我无法弄明白,更不用说找到答案,所以我要问。我要做的就是让菜单“.nav”在页面上水平居中。问题是,我想要左侧的徽标,似乎让我弄乱了导航器。
html,
body {
margin: 0;
padding: 0;
}
body {
background: url("http://i.imgur.com/4QGL09u.jpg") no-repeat center center fixed;
-wekit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#top {
width: 100%;
background-color: rgb(000, 255, 000);
}
#logo {
float: left;
margin-left: 20px;
background-color: rgb(255, 000, 000);
}
.nav {
width: 200px;
display: table;
margin: auto;
}
.item {
display: table-cell;
padding: 10px;
}
<html>
<body>
<header>
<div id="top">
<img src="http://i.imgur.com/adZJ4Ln.png" alt="logo" id="logo">
<ul class="nav">
<li class="item">Home</li>
<li class="item">Projects</li>
<li class="item">Images</li>
<li class="item">More</li>
</ul>
</div>
</header>
</body>
</html>
答案 0 :(得分:0)
是期望
的输出检查jsbin
中的输出
html,
body {
margin: 0;
padding: 0;
}
body {
background: url("http://i.imgur.com/4QGL09u.jpg") no-repeat center center fixed;
-wekit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#top {
width: 100%;
background-color: rgb(000, 255, 000);
}
#logo {
float: left;
margin-left: 20px;
background-color: rgb(255, 000, 000);
}
.nav {
width: 200px;
margin: 0 auto;
}
.item {
display: table-cell;
padding: 10px;
}
&#13;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<header>
<div id="top">
<img src="http://i.imgur.com/adZJ4Ln.png" alt="logo" id="logo">
<ul class="nav">
<li class="item">Home</li>
<li class="item">Projects</li>
<li class="item">Images</li>
<li class="item">More</li>
</ul>
</div>
</header>
</body>
</html>
&#13;