I would like to always keep the "Left" element next to the "Centered" element, taking into account that the "Centered" must always be centered:
Here is my code and a screenshot of how it looks at the moment:
* {
margin: 0;
padding: 0;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
padding: 10px;
}
.container {
background-color: #ccc;
position: relative;
text-align: center;
overflow: hidden;
}
.container>div:first-child,
.container>div:nth-child(2) {
padding: 10px 20px;
background-color: #fA5858;
color: #fff;
text-transform: uppercase;
font: 15px/1 Sans-Serif;
}
.container>div:first-child {
position: absolute;
display: block;
width: 100px;
}
.container>div:nth-child(2) {
display: inline-block;
background-color: #5882FA;
margin: 0 100px;
white-space: nowrap;
}
<div class="container">
<div>left</div>
<div>Centered</div>
</div>