I am facing an issue with assigning widths to my divisions using the CSS calc property. Despite setting the width for the first and last divisions, I am unable to allocate any width to the middle division.
HTML:
<div style="width:400px;">
<div class="first">First Division Content Goes Here.</div>
<div class="divider"></div>
<div class="last">Second Division Content Goes Here.</div>
</div>
CSS:
.first
{
height:50px;
background-color:#ff00ff;
float:left;
width: calc(50% - 10px);
}
.divider
{
width:auto;
height:50px;
background-color:#fff000;
float:left;
}
.last
{
height:50px;
background-color:#00ffff;
float:left;
width: calc(50% - 10px);
}
How can I resolve this problem? Is there a way to assign the width of the middle part based on the result of the calc property?
EDIT:
I have made updates to my JSFIDDLE by adding content to the middle division in response to suggestions that "Width auto won't assign a width automatically if there isn't any content inside the div". Now, with content added, how do I adjust the width automatically?