如何使此文本溢出效应?
此信息将在固定宽度的MUI卡中显示。这就是我的代码的样子:
cardContent: {
fontWeight: 700,
color: "#0E0E0E",
fontSize: "16px",
lineHeight: "24px",
},
cardComment: {
fontWeight: 400,
color: "#0672CB",
fontSize: "16px",
lineHeight: "24px",
textDecoration: "underline",
width: "100px",
"&:hover": {
color: "#0672CB",
textDecoration: "underline",
},
},
...
<Typography className={classes.cardContent}>
Comment: <a className={classes.cardComment}>{group.SizingComments}</a>
</Typography>
发布于 2022-10-18 15:47:24
.cardContent {
display: flex;
}
.cardComment {
width: 180px;
/*You have to provide width here*/
display: inline-block;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
<div class="cardContent">
Comment:<a class="cardComment" href="javascript:void(0);">Begining of the comment some example text</a>
</div>
.cardComment
类中,并提供width
查看text-overflow:ellipsis
的效果。.cardComment {
width: 180px;
display: inline-block;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
https://stackoverflow.com/questions/74113715
复制相似问题