隐藏溢出后换行文字消失

wrapping text disappearing after giving overflow hidden

修复此文本的换行问题 ---> 测试我在这里我在这里我在这里我在这里我在这里我 正在测试我在这里我在这里我在这里我在这里我在这里 我是 12 34 56 78 90 123 456 7778 88889 9999 999690909090

https://codesandbox.io/s/material-demo-e89n0

sportsCardHeaderItemHeadingValue: {
    fontWeight: "bold",
    fontSize: 20,
    color: "#263238",

    wordWrap: "break-word",
    lineHeight: 1.2
  },

 right_box: {
    border: "1px solid #000",
    // padding: 5,
    // background: '#ff0',
    marginTop: 8,
    marginRight: 8,
    float: "left",
    //  width: 150,
    height: 55,
    overflow: "hidden",
    lineHeight: 1.2
  },

<div className={classes.right_box}>
              0<div className={classes.sportsCardHeaderItemHeading}>Sports</div>
              <div className={classes.sportsCardHeaderItemHeadingValue}>
                testing the be Bhere I am here I am here I am here I am here I
                am testing the be Bhere I am here I am here I am here I am here
                I am 12 34 56 78 90 123 456 7778 88889 9999 999690909090
              </div>
            </div>

right_box 设置了高度,因此它无法增长 height-wise 以适应内容。此外,在调整视图大小时限制宽度时,它会溢出内容。当您将 CSS 规则 overflow:hidden; 添加到 right_box 时,它会隐藏溢出并且您看不到它。

我注释掉了高度和溢出规则(大约第 424-425 行),现在您可以看到元素扩展到填充宽度,高度增长到适合内容。

right_box: {
  border: '1px solid #000',
  // padding: 5,
  // background: '#ff0',
  marginTop: 8,
  marginRight: 8,
  float: 'left',
  //  width: 150,
  // height: 55, // don't restrict height
  // overflow: "hidden", // element can grow now so don't need to hide overflow
  lineHeight: 1.2,
},

codesandbox