I have two cells side by side.
The cells are bounded by an inner container and that container is bound by an outer container.
The idea is for the two cells to be equal width, even though their content isn't.
The width of each cell must be the width of the widest element.
The inner container will then be centered (width should be twice the widest cell).
At the moment I have two results:
- They are the same width but extend to half the available page width.
- The inner container shrinks to the center but the cells are uneven in width.
Is it possible to achieve what I want without javascript?
body {
background-color: lime;
}
.container {
margin: 20px;
}
.fb {
display: flex;
justify-content: center;
}
.fb-container {
display: flex;
align-items: center;
flex: 1;
/* flex: 0; */
background-color: #fff;
border: solid 0.1rem rgba(0,0,0,.12);
}
.fb-item {
display: flex;
align-items: center;
justify-content: center;
flex: 1;
color: rgba(0,0,0, .87);
font-size: 14px; height: 46px;
padding: 0 16px;
}
.fb-item:not(:first-child) {
border-left: solid 1px rgba(0,0,0,.12);
}
<div class="container">
<div class="fb">
<div class="fb-container">
<div class="fb-item">
<span class="fb_label">Much longer</span>
</div>
<div class="fb-item">
<span class="fb_label">Short</span>
</div>
</div>
</div>
</div>