Home > database >  CSS width not fitting content and wraps for longer text
CSS width not fitting content and wraps for longer text

Time:04-11

I am using primeng tooltip to display tooltip. I want the text to fit the content without wrapping and dont want to set fixed width.

following style not working for me.

        <a
            *ngIf="option.url"
            id="main-nav-{{ option.id }}"
            
            (click)="customNavigate(option)"
            [pTooltip]="option.label"
        >
            <i  [class]="option.icon"></i>
            <span>{{ option.label }}</span>
        </a>

.p-tooltip .p-tooltip-text {
    background: $dark;
    color: $light;
    line-height: 2.4rem;
    padding: 0.45rem 0.9rem;
    border-radius: 0.4rem;
    vertical-align: middle;
    z-index: 999999997;
    max-width: 14rem;
    border: solid 1px red;
}

In the below first image, how to get 'Event Reporting' in single line? enter image description here

enter image description here

with white-space: nowrap enter image description here

CodePudding user response:

Adding following to the above style worked for me:

white-space: nowrap;
max-width: fit-content;
width: 100em;

CodePudding user response:

Try this.

white-space: nowrap;
width: fit-content;
  • Related