javascript - 如何在 matTooltip 中添加箭头?
问题描述
我正在尝试在 matTooltip 上添加箭头,有任何方法可以在 matTooltip 上添加箭头。
<button mat-raised-button
matTooltip="Info about the action"
aria-label="Button that displays a tooltip when focused or hovered over">
Action
</button>
解决方案
您需要覆盖材质样式。并在伪元素之前/之后添加为箭头。例如,如果您需要为带有左边框和箭头的工具提示设置样式,只需执行类似的操作
.mat-tooltip {
// to make possible place arrow pseudo element outside tooltip with absolute positioning
overflow: visible;
position: relative;
&.right {
border-left: 6px solid red;
margin-left: 5px;
&::before {
position: absolute;
content: '';
display: inline-block;
background-color: red;
clip-path: polygon(50% 0, 0 50%, 50% 100%);
left: -12px;
width: 15px;
height: 15px;
top: 50%;
transform: translateY(-50%);
}
}
}
推荐阅读
- java - TaskStackBuilder 在我的智能手机上不起作用
- django - 将电子邮件传递到 django 中的路径
- sockets - 如何解密 bet365 套接字数据
- c# - “玩家”游戏对象没有附加“刚体”,但脚本正在尝试访问它
- r - 在哪里将进度条代码插入嵌套循环?
- php - mysql查询中表名的语法错误
- angular - 如果后端刷新令牌成功,如何做可见组件
- sql - 如何使用 Vertica AVG [分析]
- javascript - Woocommerce,如何编辑“已添加到购物车”消息并实现通知系统
- javascript - 如何将库 (p5.js) 添加到 Stackblitz IDE?