Page Widget How to - Align left for 20% width left bar








Question

We would like to know how to align left for 20% width left bar.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
body {<!--   ww  w . j  a va  2  s .  c om-->
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

header, footer {
  width: 100%;
  height: 100px;
  float: left;
  background: #EEE;
}

#content {
  width: 100%;
  height: 80%;
  float: left;
  background: #DDD;
}

nav {
  width: 20%;
  max-width: 250px;
  width: 250px;
  height: 100%;
  float: left;
  background: #AAA;
}
</style>
</head>
<body>
  <header>
    <h1>test layout</h1>
  </header>
  <div id="content">
    <nav>
      <ul>
        <li>link 1</li>
        <li>link 2</li>
        <li>link 3</li>
        <li>link 4</li>
        <li>link 5</li>
      </ul>
    </nav>
    <div class="inside">
      <h1>Header</h1>
      <div>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
        repellat voluptas voluptates alias.</div>
    </div>
  </div>
  <footer> stuff </footer>
</body>
</html>

The code above is rendered as follows: