Forum Moderators: not2easy
#penultimate. The same happens when a word is narrower than the min-width. <!DOCTYPE html>
<html>
<head>
<title>Example</title>
<style>
ul { display: table; list-style: none; width: 800px; }
li { margin-bottom: auto; margin-top: auto; text-align: center; text-transform: uppercase; }
li a { border: 1px solid #000; display: table-cell; float: left; max-width: 100px; min-width: 60px; padding: 0 10px; vertical-align: middle; word-wrap: break-word; }
</style>
</head>
<body>
<ul>
[pre] [/pre]<li><a href="#">blah</a></li>
<li><a href="#">blah blah</a></li>
<li><a href="#">fooooooooooooooo</a></li>
<li><a href="#">foofoo foofoo</a></li>
<li><a href="#" id="penultimate">foo foo foo </a></li>
<li><a href="#">longwordfoo</a></li>
</ul>
</body>
</html> a tag and possibly place the padding on the li.
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<style>
ul { list-style: none; width: 800px; }
li { float:left; margin-left:2%; margin-bottom: auto; margin-top: auto; max-width:14%; text-align: center; text-transform: uppercase; word-wrap: break-word; border: 1px solid #000; }
li a { padding:0 10px 6px 10px; }
</style>
</head>
<body>
<ul>
<li><a href="#">blah</a></li>
<li><a href="#">blah blah</a></li>
<li><a href="#">fooooooooooooooo</a></li>
<li><a href="#">foofoo foofoo</a></li>
<li><a href="#" id="penultimate">foo foo foo </a></li>
<li><a href="#">longwordfoo</a></li>
</ul>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<style>
ul { list-style: none; width:800px; margin:0; padding:0; background-color:#f0f0f0; }
li { float:left; margin-left:2%; max-width:14%; padding:0 10px 4px 10px;
text-align:center; text-transform:uppercase; word-wrap:break-word; border:1px solid #000; }
ul:after, ul li:last-child:after {
content:' ';
display:block;
height:0;
clear:left;
}
</style>
</head>
<body>
<ul>
<li><a href="#">blah</a></li>
<li><a href="#">blah blah</a></li>
<li><a href="#">fooooooooooooooo</a></li>
<li><a href="#">foofoo foofoo</a></li>
<li><a href="#" id="penultimate">foo foo foo </a></li>
<li><a href="#">longwordfoo</a></li>
</ul>
<p>More</p>
</body>
</html>
li { margin-bottom: auto; margin-top: auto; text-align: center; text-transform: uppercase; }
li a { border: 1px solid #000; display: table-cell; float: left; max-width: 100px; min-width: 60px; padding: 0 10px; vertical-align: middle; word-wrap: break-word; }
<html>
<head>
<title>Example</title>
<style>
ul {
display: table;
list-style: none;
width: 100%;
}
li {
float: left;
margin-bottom: auto;
margin-top: auto;
text-align: center;
}
li a {
display: table-cell;
font-size: 11px;
height: 60px;
max-width: 100px;
min-width: 50px;
padding: 0px 5px;
text-decoration: none;
text-transform: uppercase;
vertical-align: middle;
}
</style>
</head>
<body>
<ul>
<li><a href="#">blah</a></li>
<li><a href="#">blah blah</a></li>
<li><a href="#">foooooooo foooooooo</a></li>
<li><a href="#">foofoo foofoo</a></li>
<li><a href="#" id="penultimate">foo foo foo </a></li>
<li><a href="#">longwordfoo</a></li>
</ul>
</body>
</html>
| | ---------- | | |
| --- | ---------- | ----- | ---- ---- |
| | ---- | | |
<script>
var width = $('ul li').each(function(){
var innerWidth = $(this).innerWidth();
$(this).css('width',innerWidth + 'px');
});
</script>