shelly
shelly

Reputation: 319

Bootstrap 4 tooltip text-align left

im using the Bootstrap tooltip with html.

<span rel="tooltip" data-toggle="tooltip" data-trigger="hover" data-placement="right" data-html="true" data-title="{$some_html}">test</span>

I want to set the text-align inside the tooltip to left. Every similiar problem i found was solved by using:

.tooltip-inner {
     text-align: left!important;
}

But it seems not to work for me.

Upvotes: 1

Views: 2759

Answers (1)

johannchopin
johannchopin

Reputation: 14844

By default, the tooltip will fit the content width. So if you don't change the size of the tooltip you will not see the result of text-align: left!important;. If you add a biggest width to the tooltip you will see it impact:

$(document).ready(function() {
  $('[data-toggle="tooltip"]').tooltip();
});
.tooltip {
  width: 100px;
}

.tooltip-inner {
  text-align: left!important;
}
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>

<body>

  <div class="container">
    <h3>Tooltip Example</h3>
    <a href="#" data-toggle="tooltip" title="Hooray!">Hover over me</a>
  </div>

</body>

Upvotes: 3

Related Questions