Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.7k views
in Technique[技术] by (71.8m points)

How to modify bootstrap 4.5 tooltip css?

With bootstrap 4.5.3 I make tooltip and I want to change default appearence. With my styles defined :

.tooltip {
    display: flex;
    justify-content: flex-start;
    position: absolute;
    z-index: 9999;
    background: #ddff9d;
    color: #333333;
    width: 320px;
    
    -webkit-box-shadow: 5px 5px 5px 5px white;
    box-shadow: 2px 2px 2px 2px white;
    -moz-border-radius: 8px;
    border-radius: 8px;
    -webkit-border-radius: 8px;
    opacity: 1 !important;

    padding: 10px;
    text-align: left;
}

.tooltip-inner {
    background-color: #00acd6 !important;
    /*!important is not necessary if you place custom.css at the end of your css calls. For the purpose of this demo, it seems to be required in SO snippet*/
    color: #fff;
}

.tooltip.top .tooltip-arrow {
    border-top-color: #00acd6;
}

.tooltip.right .tooltip-arrow {
    border-right-color: #00acd6;
}

.tooltip.bottom .tooltip-arrow {
    border-bottom-color: #00acd6;
}

.tooltip.left .tooltip-arrow {
    border-left-color: #00acd6;
}

I have : https://prnt.sc/wlwp1v

and I want how :

  1. Change width of internal (blue) block to fill width+paddings
  2. Set equal paddings of internal block with external
  3. To align text inside of internal block to the left ?

MODIFIED BLOCK: That is actually fullcalendar 3.9 component and tooltip is rendered on fly with javascript code:

  eventRender: function (eventInfo, element, view) {
  let adHtml = '<b>' + eventInfo.title + "</b><br> " +
        '<u>{!! showAppIcon('expire_date') !!} Expired at : ' + eventInfo.start_formatted + '</u><br>'+
        '{!! showAppIcon('location') !!}&nbsp;' + eventInfo.adLocationsCount + '&nbsp;location(s)<br>' +
        '<small>Status : ' + eventInfo.status_label + "</small><br>" +
        '<small>' + eventInfo.description + "</small>"

    let tooltipOptions = {
        title: adHtml,
        html: true
    }

   element.tooltip(tooltipOptions)

I use this bootstrhttps://bootswatch.com/solar as template... I can not debug elements in browser's inspactor, as when mouse is hover tooltip is hidden...

Thanks!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To change the width just use: max-width: 400px;. To left-align text just simply use text-align: left;

Replace your whole CSS with the given below:

.tooltip-inner {
  text-align: left;
  max-width: 400px;
  border-radius: 8px;
  padding: 20px;
}

Codepen: https://codepen.io/manaskhandelwal1/pen/LYRXzro


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...