<button md-button class="link-btn" >Cancel</button> .link-btn { background-color: transparent; background-repeat: no-repeat; border: none; cursor:pointer; overflow: hidden; outline:none; font-size: 0.8em; padding: 0px; } .link-btn:hover { background-color: transparent; background-repeat: no-repeat; border: none; cursor:pointer; overflow: hidden; outline:none; font-size: 0.8em; padding: 0px; }
解决方法
Some Angular Material components,specifically overlay-based ones like
MatDialog,MatSnackbar,etc.,do not exist as children of your
component. Often they are injected elsewhere in the DOM. This is
important to keep in mind,since even using high specificity and
shadow-piercing selectors will not target elements that are not direct
children of your component. Global styles are recommended for
targeting such components.
在按钮悬停背景的特定情况下,我必须在styles.css中使用以下代码(通过angular-cli包含的全局样式表或在index.html中直接链接).请注意,您可能必须使用重音或警告替换primary,具体取决于按钮中使用的调色板类型(color =“primary”或color =“accent”或color =“warn”).
.mat-button.mat-primary .mat-button-focus-overlay { background-color: transparent; }
如果您不希望每个按钮都受到影响,最好有一个特定的类,如no-hover-effect,如下所示.
.no-hover-effect.mat-button.mat-primary .mat-button-focus-overlay,.no-hover-effect.mat-button.mat-accent .mat-button-focus-overlay,.no-hover-effect.mat-button.mat-warn .mat-button-focus-overlay { background-color: transparent; }
对于每个不需要悬停效果的素材按钮,你都可以
<button mat-button color="primary" class="no-hover-effect"> No Hover Button </button>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。