9

body {
 margin: 0;
}

.header {
    width: 80%;
    height: 20%;
    margin-left: 10%; 
    position: fixed;
    top: 0; 
    box-sizing: border-box;
    border-style: solid;
    border-width: 1px;
    background-color: green;
}

.image {
    width: 20%;
    height: 100%;
    float: left;
    box-sizing: border-box;
    border-style: solid;
    border-width: 1px;
}

.navigation {
    width: 79%;
    height: 100%;
    float: right;
    text-align: right;
    box-sizing: border-box;
    border-style: solid;
    border-width: 1px;
}

ul {
    height: 100%;
    font-size: 0;
    box-sizing: border-box;
    border-style: solid;
    border-width: 1px;
    background-color: yellow;
}

li {
    height: 100%;
    font-size: initial;
    display: inline-block;
    box-sizing: border-box;
 border-style: solid;
 border-width: 1px;
    background-color: blue;
}
<div class="header"> 

      <div class="image">
      Image
      </div>
  
      <nav class="navigation"> 
        <ul>
          <li> 1.0 Main Menu </li>
          <li> 2.0 Main Menu </li>
          <li> 3.0 Main Menu </li>
        </ul>
      </nav>
      
</div>

With the above code I have created a <header> containing of an <image> and a <navigation>. All this works fine so far.

Now I want that the text inside the <li> element appears in the center. Therefore, I tried to go with the property text-align: center; in the li CSS but it did not work.

What do I have to change in my code to get the text within the <li> elements centered?

You can also find my code here: https://jsfiddle.net/5jv8m5xf/39/

Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
Michi
  • 4,663
  • 6
  • 33
  • 83
  • 1
    @Michi you want to have *vertical* alignment of the text? – kukkuz Aug 20 '17 at 14:10
  • https://stackoverflow.com/questions/33049010/how-to-center-text-in-li – Sven van den Boogaart Aug 20 '17 at 14:15
  • I have tried use the `text-aling:center ` and its works. I was not able to see the effect because the
  • width is so small, if you increment it maybe you will see.
  • – Yago Azedias Aug 20 '17 at 14:24