Yama Yama - 1 month ago 7
HTML Question

Positioning Table in Center of Page

It seems like there is a simple fix to this but I cannot figure it out, much less find an answer so I am going to ask. All I am trying to do is get the menu ".nav" centered horizontally on the page. The problem is, I want the logo on the left and it seems to be messing with me centering the nav.

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>


CSS

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;
}

Answer

is this output r u expecting

check output in 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;
}
<!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>