CSS сетка может сделать это, как показано ниже:
.container {
margin: 10px;
display: grid;
grid-template-columns: 1fr minmax(0,max-content) 1fr;
color: #fff;
}
.container::before {
content:"";
}
.b {
margin-left: auto;
background: grey;
}
.a {
margin: auto;
background: blue;
overflow:hidden;
text-overflow:ellipsis;
max-width:100%;
}
body {
background:linear-gradient(red,red) center/ 2px 100% no-repeat;
}
<div class="container">
<div class="a">AA</div>
<div class="b">BBBBBBBBBBBBBBBB</div>
</div>
<div class="container">
<div class="a">AA</div>
<div class="b">BBBBBBBBBBBBBBBB</div>
</div>
<div class="container">
<div class="a">AAAAAAAAAAAAAA</div>
<div class="b">BBBBBBBBBBBBBBBB</div>
</div>
<div class="container">
<div class="a">AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</div>
<div class="b">BBBBBBBBBBBBBBBB</div>
</div>
<div class="container">
<div class="a">AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</div>
<div class="b">BBBBBBBBBBBBBBBB</div>
</div>