Here is html:
<div class="container>
<div class="header">
</div>
<div class="content">
</div>
<div class="footer">
</div>
</div>
I want container to have the size of the content div. BUT I want the widths of header and footer be constrained by the size of the content/container.
display:inline-block alone does not work because container adapts its size to the widest child.
The width of the content is unknown so explicit width settings can not be set.
Here is the image explaining what behavior I need.

In other words: footer and header follow the width of container. Size of the content defines container width.