0

I specified a fixed width to my 'left box', but if the right content is too long the width is shrink, it's no longer 10px, how to prevent that?

.flex {
  display: flex;
}

.left {
  width: 10px;
  height: 10px;
  border: 1px solid;
}

.right {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}
<div class="flex">
  <div class="left">

  </div>
  <div class="right">
    hello world this and that etc hello world this and that etc hello world this and that etc hello world this and that etc hello world this and that etc
  </div>
</div>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415
Neini Amanda
  • 679
  • 1
  • 5
  • 12

1 Answers1

0

Define the leftbox flex-shrink to be0:

.flex {
  display: flex;
}

.left {
  width: 10px;
  height: 10px;
  border: 1px solid;
  flex-shrink: 0;
}

.right {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}
<div class="flex">
  <div class="left">

  </div>
  <div class="right">
    hello world this and that etc hello world this and that etc hello world this and that etc hello world this and that etc hello world this and that etc
  </div>
</div>
Ori Drori
  • 183,571
  • 29
  • 224
  • 209