Rup*_*esh 5 html javascript css angular-material angular
我正在尝试制作一个通知系统,所以我正在使用mat-menufrom角材料。我增加了的宽度,menu-item但问题是它没有显示完整的内容。它仅显示一行中的文本。
但如果文本超出了该行,我想将文本换行
我的 compontent.html
<button mat-button [matMenuTriggerFor]="notification"><mat-icon>add_alert</mat-icon></button>
<mat-menu #notification="matMenu" [overlapTrigger]="false" class="my-full-width-menu">
<button mat-menu-item style="white-space: normal">
Learn one way to build applications with Angular and reuse your code and abilities to build
apps for any deployment target. For web, mobile web, native mobile and native desktop.
</button>
<button mat-menu-item>Item 2</button>
</mat-menu>
Run Code Online (Sandbox Code Playgroud)
并且CSS是
.mat-menu-panel.my-full-width-menu {
max-width: none;
width: 100vw;
margin-left: -8px;
margin-top: 24px;
}
Run Code Online (Sandbox Code Playgroud)
请告诉我该怎么做。
该mat-menu-item班有静line-height,静height到48px是防止它自动换行。
::ng-deep button.mat-menu-item {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
cursor: pointer;
outline: 0;
border: none;
-webkit-tap-highlight-color: transparent;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: block;
/** set line height to desired height */
line-height: 18px;
/** set height to auto */
height: auto;
padding: 0 16px;
text-align: left;
text-decoration: none;
max-width: 100%;
position: relative;
}
Run Code Online (Sandbox Code Playgroud)
要设置菜单宽度,请使用以下命令。
::ng-deep div.mat-menu-panel {
min-width: 112px;
/** set width to 500px */
max-width: 500px;
overflow: auto;
-webkit-overflow-scrolling: touch;
max-height: calc(100vh - 48px);
border-radius: 4px;
outline: 0;
}
Run Code Online (Sandbox Code Playgroud)
闪电战
https://stackblitz.com/edit/angular-qzbutg?embed=1&file=app/menu-overview-example.css
| 归档时间: |
|
| 查看次数: |
1601 次 |
| 最近记录: |