我目前正在使用 md-tab-group (昨天刚刚更新到最新版本)...
有谁知道吗
disableRipple 作为属性,使用 Angular 材质禁用 md-tab-group
的波纹,就像Angular2+ 一样。 只需做这样的事情:
<md-tab-group disableRipple></md-tab-group>
此外,如果您使用的是
最新的角度材质,它会有点不同,如下所示:
<mat-tab-group [disableRipple]="true"></mat-tab-group>
Angular 的当前版本是 15.2.6。 这是使用像 MatStepper: 这样的组件时对我有用的唯一方法
app.module.ts
import {MatRippleModule, MAT_RIPPLE_GLOBAL_OPTIONS } from '@angular/material/core';**
@NgModule
的装饰器中,您应该在 providers[]
数组中提供它:
providers: [{provide: MAT_RIPPLE_GLOBAL_OPTIONS, useValue: {disabled: true}}]
/deep/
/* your-component.component.scss file*/
/deep/ .md-tab-label {
min-width: 0px; /* Or whatever value you wish */
/* In some situations !important seems necessary */
}
<!-- your-component.component.html -->
<!-- Template from Angular Material's Github Readme.md -->
<md-tab-group>
<md-tab>
<template md-tab-label>
The <em>best</em> pasta
</template>
<h1>Best pasta restaurants</h1>
<p>...</p>
</md-tab>
<md-tab>
<template md-tab-label>
<md-icon>thumb_down</md-icon> The worst sushi
</template>
<h1>Terrible sushi restaurants</h1>
<p>...</p>
</md-tab>
</md-tab-group>
纯CSS
/* overrides.css */
.md-tab-label ,.md-tab-label-active {
min-width: 0; /* same comments as the first solution */
}
<!-- index.html -->
<link rel="stylesheet" content="text/css" href="overrides.css">
两者都有点脏,但第一个为我提供了一个很好的解决方案来覆盖 md 组件的样式,将更改保留在相关组件内(考虑仅包装这些组件以进行本地更改)。
<mat-checkbox
formControlName="yes"
disableRipple
>Yes
</mat-checkbox>
将样式规则添加到 styles.scss 或 styles.css:
.mdc-checkbox__ripple {
display: none;
}
CSS-Grid。在最后一列中,您有一个 MaterialMenu
(由
MaterialIconButton
激活)。在不同的列中,您选择使用替代方案
MaterialIcon
(无按钮),并发现随着窗口宽度的减小,它无法在网格布局内保持正确的垂直对齐。因此,您将其
MaterialIcon
更改为
MaterialIconButton
并看到,现在所有内容都完全垂直居中。这里是 div 框(Chrome 调试 CSS 扩展显示垂直居中):
您现在在这个
MaterialIconButton
(例如灯泡)上遇到悬停和波纹效果
,这可能被视为侵入性的。在这种情况下,建议消除这些影响:
导入必要的模块(摘录):
imports: [
// ...
MatIconModule,
MatButtonModule,
MatRippleModule,
],
禁用波纹,如:
<div class="lightbulb-container">
<button mat-icon-button [disableRipple]="true">
<mat-icon>lightbulb</mat-icon>
</button>
</div>
覆盖此 MatIconButton Hover
并删除
Cursor
:
.lightbulb-container {
button {
cursor: initial;
--mat-icon-button-state-layer-color: transparent;
}
}