Am I using ngx-tooltip in angular material, but the tooltip is clipped to adjust the z-index?

I am using ngx-tooltip ( https://www.npmjs.com/package/ngx-tooltip ) with angular.material.io tabs and I run into a problem when the tooltip seems to crop on the left side when inside the container md-tab. How to make a tooltip pop up over everything? Is there a way to change the z-index of the tooltip or is there some other way?

the code:

<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>
+4
source share
2 answers

plunker. md-tab, (. ):

  • ViewEncapsulation.None:
import {ViewEncapsulation} from '@angular/core';

@Component({
  ...
  styleUrls: ["./tabs-overview-example.css"],
  encapsulation: ViewEncapsulation.None
})
  1. CSS overflow :
md-tab-group,
md-tab-body,
.mat-tab-body-wrapper,
.mat-tab-body-content
{
    overflow: visible !important;
}
+5

, #myTooltip ,

import {Input, ElementRef, AfterViewInit, Component } from '@angular/core';

@Component(...)
export class MyComponent implements AfterViewInit {
    @Input() myTooltip: ElementRef;

    ngAfterViewInit() {
        this.myTooltip.nativeElement.style.zIndex = '9999 !important';
    }
}
+2

Source: https://habr.com/ru/post/1679856/


All Articles