First child grow width of content until parent boundary invokes overflow ellipses

前端 未结 3 1743
逝去的感伤
逝去的感伤 2021-01-25 23:38

So a quick visual of what I\'m trying to accomplish wherein the (gray) parent container is of variable width. The first child (red) is of variable auto width depending on its co

3条回答
  •  没有蜡笔的小新
    2021-01-25 23:58

    You can do this with flexbox like below:

    .container {
      display:flex;
      border:2px solid;
      width:500px;
    }
    .container > div:last-child {
      width:100px;
      border:2px solid green;
      flex-shrink:0;
    }
    .container > div:first-child { 
      border:2px solid red;
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
    }
    some text
    some text some text some text some text some text some text some text some text

提交回复
热议问题