I have a CSS solution for you, check out this Working Fiddle
DownSide: it requires to Double the ul
li
elements,
(one of them is for taking the real space in the document flow, (he don't render as we want but so will be hidden), and one of them is showed, on top of the other, with the display you want.
HTML:
<div class="Container">
<ul class="Hidden">
<li>This stays on one line</li>
<li>And this</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed auctor libero neque, nec tristique metus rutrum et. Integer semper libero quis magna placerat, a posuere sem congue.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed auctor libero neque, nec tristique metus rutrum et. Integer semper libero quis magna placerat, a posuere sem congue.</li>
</ul>
<ul class="Visible">
<li>This stays on one line</li>
<li>And this</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed auctor libero neque, nec tristique metus rutrum et. Integer semper libero quis magna placerat, a posuere sem congue.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed auctor libero neque, nec tristique metus rutrum et. Integer semper libero quis magna placerat, a posuere sem congue.</li>
</ul>
</div>
CSS:
*
{
padding: 0;
margin: 0;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.Container
{
position: relative;
}
.Hidden
{
visibility: hidden;
}
.Visible
{
position: absolute;
top: 0;
height: 100%;
}
ul
{
white-space: nowrap;
background-color: #cccccc;
font-size: 0;
}
li
{
display: inline-block;
padding: 10px;
border-right: 1px solid red;
background-color: #2c2c2c;
text-align: center;
color: #fefefe;
white-space: normal;
vertical-align: top;
font-size: 16px;
height: 100%;
}
li:last-child
{
width: 100%;
border-right: 1px solid #2b2b2b;
}