0

Id like to keep the <li>s aligned evenly at the top, here's my CSS:

ul {
   list-style-type:none;
   margin:0;
   padding:0;
   width:510px; 
}

li {
   width:230px;
   border:1px solid #ccc;
   padding:5px;
   float:left;
   margin:5px 5px 0 0;  
}

Here is in action.

Any way to align the top of the <li>s evenly?
Here is a picture of what I would like it to be: Example layout

totymedli
  • 29,531
  • 22
  • 131
  • 165
Richard
  • 1,414
  • 2
  • 16
  • 27

2 Answers2

2

Instead float, use display: inline-block; vertical-align: top;

http://jsfiddle.net/t6tML/11/

Miljan Puzović
  • 5,840
  • 1
  • 24
  • 30
0

The width of the ul needs to equal the combined width of the li elements:

ul {
    list-style-type:none;
    margin:0;
    padding:0;
    width: 1482px;
}

Each of your li elements has a width of 230px, 5px horizontal margin, 10px horizontal padding, and 2px horizontal border so:

230 + 5 + 10 + 2 = 247px

247 * 6 li elements = 1482px

Full code: http://jsfiddle.net/t6tML/3/

chrx
  • 3,524
  • 1
  • 15
  • 17