JSFiddle - React, Tailwind, and code Playground
HTML
<div id='wrapper'>
<div id="boxadoo">
<ul>
<li>Box 1</li>
<li>Box Two</li>
<li>Tres Box</li>
<li>Box Box Box Box</li>
<li>Box (Box * 5)</li>
<li>Boxcar Racer</li>
</ul>
</div>
</div>
CSS
#wrapper {
position:absolute;
background-color: #ccc;
width: auto;
min-width: 100%;
background-color: #FFFFFF;
top:44px;
left: 0;
right: 0;
height: 48px;
line-height: 46px;
overflow-x: hidden;
z-index:100001;
color: #CCC;
font-family: "Helvetica Neue Bold", Helvetica;
}
#boxadoo {
width: auto;
overflow: hidden;
}
#boxadoo ul {
background-color: #eee;
font-size: 1em;
color: black;
position: relative;
left: 0;
width: auto;
margin: 0;
padding: 0;
}
#boxadoo li {
background-color: pink;
display: inline-block;
margin: 0;
padding: 0 10px 0 0;
}
JavaScript
var elem = $('#boxadoo').find('ul'),
width = 0;
console.log(">> Setting dynamic width: " + width);
elem.find('li').each(function(){
console.log(width + ' += ' + $(this).outerWidth());
width += $(this).outerWidth();
})
console.log("Final width: "+width);
elem.css('width', width);