I need to shrink fit a parent to fit a child div that itself has a max-width set.
The problem is that once the child's content overflows onto multiple lines it's width is set to it's max width, even though it doesn't need to be that wide. Here, I want the gray outer box to fit the contents exactly.
Here's the code:
<div class="tags">
<ul>
<li>One
<li>Two
<li>Three
<li>Four
</ul>
</div>
.tags {
max-width: 190px;
background: #AAA;
}
.tags ul {
list-style-type: none;
padding: 0;
text-align: right;
}
.tags li {
display: inline-block;
margin-bottom: 5px;
margin-right: 5px;
padding: .2em .6em .3em;
font-size: 20px;
font-weight: bold;
line-height: 1;
color: #ffffff;
text-align: center;
border-radius: .25em;
background-color: #579cc1;
}
I have a fiddle here:
Anyone have a solution to this?