Here is the basic html, the .left and .right divs I have no control over their widths, they could be smaller or greater that I have now, but regardless of their width I need to keep the center div always in the center of the .inner container.
Because left is only 200px wide and right is 400px wide, the .center container is not in the center.
.header{
background-color: blue;
height: 60px;
width: 100%;
}
.inner{
width: 1200px;
margin: 0 auto;
height: 60px;
background-color: pink;
}
.left{
width: 200px;
min-width: 0px;
max-width: 500px;
height: 60px;
background-color: red;
display: inline-block;
opacity: 0.2;
}
.center{
width: 100px;
height: 60px;
background-color: blue;
display: inline-block;
margin: 0 auto;
opacity: 1;
}
.right{
width: 400px;
min-width: 0px;
max-width: 500px;
height: 60px;
background-color: red;
float: right;
opacity: 0.2;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div class="header">
<div class="inner">
<div class="left"></div>
<div class="center"></div>
<div class="right"></div>
</div>
</div>
</body>
</html>
I have uploaded the jsbin here
Any pointers or solutions most welcome