如何通过将文本包装在按钮内来确保Angular Material Button内的文本不会溢出。我尝试了以下方法:
<div class="cotnainer">
<button mat-raised-button color="accent">Click me! This is a long text, but I want to to wrap if content is overflowing
</button>
</div>
.container{
width: 200px;
height:200px;
background-color: silver;
}
button{
max-width: 100%;
}
span, .mat-button-wrapper{ // I have tried all of the following options, but it does not work.
max-width: 100% !important;
word-break: break-all !important;
overflow: hidden !important;
}
这里是Stackblitz
编辑 当前结果:
答案 0 :(得分:3)
您可以使用以下代码来实现:
隐藏:
button {
overflow-x: hidden !important;
}
分词:
button{
white-space: pre-wrap !important;
}