1

I have nested flex items like this (https://jsfiddle.net/e1bm2s2x/1):

As you shrink the width of the outside container (I drag the width of the JSFiddle pane), container-2 first shrinks and the text overflows with ellipses. That is what I want. But then it stops shrinking and overflows the parent container. I would like for container-2 to keep shrinking instead of overflowing container-1. I've played with this a lot but to no avail. Is this possible?

* {
  box-sizing: border-box;
}
.container {
  display: flex;
  align-items: center;
}

.container-1 {
  border: 3px solid orange;
}

.container-2 {
  border: 3px solid green;
  flex: 1 1 0;
}

.content {
  flex: 1 1 0;
  margin-right: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fixed {
  flex: 0 0 50px;
  border: 3px solid brown;
}
<div class="container container-1">
  <div class="fixed">
    left
  </div>
  <div class="container container-2">
    <div class="content">
      words words words words words words words
    </div>
    <button class="fixed">
      right
    </button>
  </div>
</div>
Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
Dmitry Minkovsky
  • 36,185
  • 26
  • 116
  • 160

0 Answers0