首页 > 其他分享 >flex布局处理文本溢出

flex布局处理文本溢出

时间:2022-11-22 12:33:21浏览次数:45  
标签:flex 中文 right 这是 一段 文本 溢出

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>flex布局处理文本溢出</title>
  <style>
  .container {
    display: flex;
  }

  .left, .right {
    flex: 1;
  }

  .right {
    /* right设置了flex后,也要设置width: 0;。
      不然会被child撑开,而导致文本无法超出隐藏 */
    width: 0;
    background: red;
  }

  .text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  </style>
</head>
<body>
<div class="container">
  <div class="left text">这是一段中文这是一段中文这是一段中文这是一段中文这是一段中文这是一段中文</div>
  <div class="right">
    <div class="child text">这是一段中文这是一段中文这是一段中文这是一段中文这是一段中文这是一段中文</div>
  </div>
</div>
</body>
</html>

标签:flex,中文,right,这是,一段,文本,溢出
From: https://www.cnblogs.com/linding/p/16914757.html

相关文章