Page Widget How to - Float menu and change background








Question

We would like to know how to float menu and change background.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.menu {<!--   w w  w  .  j a  va  2 s .  c o m-->
  width: 100%;
  background-color: #2586d7;
  position: absolute;
}

#button {
  padding: 0;
}

#button li {
  display: inline;
}

#button li a {
  font-family: Arial;
  font-size: 14px;
  text-decoration: none;
  float: left;
  padding: 10px;
  background-color: #000;
  color: #fff;
}

#button li a:hover {
  background-color: #2586d7;
  margin-top: -2px;
  padding-bottom: 12px;
}
</style>
</head>
<body>
  <div class="menu">
    <ul id="button">
      <li><a href="">Item</a></li>
      <li><a href="">Item</a></li>
      <li><a href="">Item</a></li>
      <li><a href="">Item</a></li>
    </ul>
  </div>
</body>
</html>

The code above is rendered as follows: