我将 ngx-tooltip ( https://www.npmjs.com/package/ngx-tooltip ) 与 angular.material.io 选项卡一起使用,我遇到了一个问题,即在 md-tab 容器内部时,工具提示似乎在左侧被截断。如何使工具提示浮在所有内容之上?有什么方法可以调整工具提示的 z-index 还是有其他方法?
代码:
<md-tab-group>
<md-tab label="Tab 1">
<!-- tooltip with dynamic html content -->
<div>
<tooltip-content #myTooltip>
<b>Very</b> <span style="color: #C21F39">Dynamic</span> <span style="color: #00b3ee">Reusable</span>
<b><i><span style="color: #ffc520">Tooltip With</span></i></b> <small>Html support</small>.
</tooltip-content>
<button [tooltip]="myTooltip">hover this button to see a tooltip</button>
</div>
</md-tab>
</md-tab-group>
最佳答案
我在 this plunker 中重现了您的问题.为了使工具提示在 md-tab 容器外可见,我必须执行以下操作(参见 this corrected plunker):
- 在组件装饰器中,我将封装设置为
ViewEncapsulation.None
:
import {ViewEncapsulation} from '@angular/core';
@Component({
...
styleUrls: ["./tabs-overview-example.css"],
encapsulation: ViewEncapsulation.None
})
- 在 CSS 文件中,我将
overflow
属性设置如下:
md-tab-group,
md-tab-body,
.mat-tab-body-wrapper,
.mat-tab-body-content
{
overflow: visible !important;
}
关于angular - 我在 Angular Material 中使用 ngx-tooltip,但工具提示被切断,有什么方法可以调整 z-index?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44689595/