Catalin Catalin - 5 months ago 19
CSS Question

6 column fluid layout

I'm trying to achieve a 6 column fluid layout, like so:

<ul class="list">
<li class="list-element first">
<a>Item 1</a>
</li>
<li class="list-element">
<a>Item 2</a>
</li>
<li class="list-element">
<a>Item 3</a>
</li>
<li class="list-element">
<a>Item 4</a>
</li>
<li class="list-element">
<a>Item 5</a>
</li>
<li class="list-element last">
<a>Item 6</a>
</li>
</ul>


My list should be 100% width and every list element LINK (ul li a) should fit equally into it. Did some research and didn't find any 6 column fluid layout to match my request (or I'm just too tired to see it).

Any oppinion?

TIA

Answer

Use the css float on the li and a width of 16.66666666666667% this means 100/6.

here is a sample css. and a fiddle

  .list {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  .list li {
    width: 16.66666666666667%;
    float: left;
  }
  .list li a {
    display: block;
    border: 1px solid #ddd;
    text-align: center;
  }
<ul class="list">
  <li class="list-element first">
    <a>Item 1</a>
  </li>
  <li class="list-element">
    <a>Item 2</a>
  </li>
  <li class="list-element">
    <a>Item 3</a>
  </li>
  <li class="list-element">
    <a>Item 4</a>
  </li>
  <li class="list-element">
    <a>Item 5</a>
  </li>
  <li class="list-element last">
    <a>Item 6</a>
  </li>
</ul>