Page Widget How to - Turn UL to table to create navigation menu








Question

We would like to know how to turn UL to table to create navigation menu.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
ul {<!--from w  w w . j  a  v  a 2s . c o  m-->
  display: table;
  text-align: center;
  width: 100%;
}

li {
  background-color: #eee;
  display: table-cell;
  padding: 5px;
}

li:nth-child(2n) {
  background-color: #ddd;
}
</style>
</head>
<body>
  <ul>
    <li>A</li>
    <li>B</li>
    <li>C</li>
    <li>D</li>
    <li>E</li>
    <li>F</li>
    <li>G</li>
  </ul>
</body>
</html>

The code above is rendered as follows: