给父级元素加width: 0;

<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <meta name="viewport" content="width=device-width, initial-scale=1.0">  <title>Document</title>  <style>    *{      margin: 0;      padding: 0;    }    #box {      width: 300px;      display: flex;      justify-content: space-between;      /* align-items: center; */      border: 1px solid red;      box-sizing: border-box;      line-height: 50px;    }    .left{      background-color: yellowgreen;      flex: 1;      // 父元素设置宽度为0      width: 0;    }    .text {      overflow: hidden;      text-overflow: ellipsis;      white-space: nowrap;      height: 50px;    }    .right {      width: 100px;      /* height: 50px; */      background-color: #e4b9b9;      /* border-radius: 10px; */    }  </style></head><body>  <div id="box">    <div class="left">      <p class="text">内容内容内容内容内容内容内容内内容内容内容内容内容内容内容内容内容内容内容内容容内容内容内容内容</p>    </div>    <div class="right">我在左边</div>  </div></body></html>