问题描述
我的MuiCardHeader有问题
<CardHeader
disableTypography
avatar={renderAvatar()}
action={
<IconButton onClick={toggleMenu}>
<img src={MoreIcon} alt=""/>
</IconButton>
}
title={
<Typography Nowrap variant="subtitle1">
{data.name}
</Typography>
}
subheader={
<Typography variant="subtitle2" color="textSecondary">
{data.children.items.length} items
</Typography>
}
/>
如何预防呢?
我需要的结果
这是代码沙箱
https://codesandbox.io/s/dazzling-paper-5d35h?file=/src/App.js
UPD:解决方案
textOverflow: "ellipsis",overflow: "hidden",whiteSpace: "Nowrap",
到.MuiCardHeader-content
类
感谢大家的帮助!
解决方法
您需要使用text-overflow: ellipsis
,overflow: hidden
和white-space: nowrap
因此,在您的情况下,您只需将.MuiTypography-noWrap
添加到父级 .MuiCardHeader-content