2

Here is my problem

header {
  width: 100%;
  height: 81px;
  background: #669999;
  line-height: 81px;
}

header nav {
  float: right;
  margin-right: 15%;
  background: green;
}

header nav ul {
  background: yellow;
  width: 650px;
}

header nav li {
  display: inline-block;
  margin-left: 20px;
  width: 180px;
  height: 36px;
  background: #006666;
  margin-top: 20px;
  margin: auto;
}

header nav li a {
  background: red;
  margin: auto;
}
<header>
  <nav>
    <ul>
      <li><a href="">About</a></li>
      <li><a href="">Works</a></li>
      <li><a href="">Contact</a></li>
    </ul>
  </nav>
</header>

I wonder why the <a> link are not align inside <li> list?

The <a> link is vertical aligned from header so it's perfect but <li> list is above.

Temani Afif
  • 245,468
  • 26
  • 309
  • 415
Eza bilam
  • 25
  • 4
  • Possible duplicate of [How do I vertically center text with CSS?](https://stackoverflow.com/questions/8865458/how-do-i-vertically-center-text-with-css) – Samuel Hulla Jun 10 '18 at 12:24

3 Answers3

0
  1. set text-align: center; to li
  2. remove the height of li OR increase it (to height: 81px;)

* {
 margin:0;padding:0;
}
header {
 width:100%;
 height:81px;
 background:#669999;
 line-height: 81px;

}
header img {
 margin-left:15%;
 margin-top:20px; /* 50% img-height */
}
header nav {
 float:right;
 margin-right:15%;
 background: green;
}
header nav ul {
 background:yellow;
 width:650px;

}
header nav li {
    display: inline-block;
    margin-left: 20px;
    width: 180px;
    /* height: 36px; */
    background: #006666;
    margin-top: 20px;
    margin: auto;
    text-align: center;
}
header nav li a {
 background:red;
 margin:auto;
}
<!DOCTYPE html>
<html>
<head>
 <title></title>
 <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
 <header>
  <nav>
   <ul>
    <li><a href="">About</a></li>
    <li><a href="">Works</a></li>
    <li><a href="">Contact</a></li>
   </ul>
  </nav>
 </header>
</body>
</html>
לבני מלכה
  • 15,925
  • 2
  • 23
  • 47
  • Thanks for answer. But i want to do a button for each
  • & if i do width;100px (for example), the background of li isn't 100px width but only the text width...
  • – Eza bilam Jun 10 '18 at 12:31