Home > Web Front-end > CSS Tutorial > How Can I Change the Color of Bootstrap Tooltips?

How Can I Change the Color of Bootstrap Tooltips?

Linda Hamilton
Release: 2024-12-18 04:31:14
Original
756 people have browsed it

How Can I Change the Color of Bootstrap Tooltips?

How to Change Bootstrap Tooltip Color

Changing the tooltip color in Bootstrap allows you to customize its appearance to match your website's design. This can be achieved by adding custom CSS styles.

To change the tooltip color, start by assigning a unique class to the element where you're using the tooltip. For example:

<a href="#" data-toggle="tooltip" data-placement="bottom"
   title="" data-original-title="Tooltip on bottom"
   class="red-tooltip">Tooltip on bottom</a>
Copy after login

Next, add the following CSS rules:

.tooltip-arrow,
.red-tooltip + .tooltip > .tooltip-inner {
  background-color: #f00;
}
Copy after login

This will change the tooltip's arrow and inner background to red. You can replace #f00 with any desired color code to customize the tooltip's color.

In Bootstrap 4, you may need to specifically target the bottom placement arrow to remove the default black color:

.red-tooltip + .tooltip.top > .tooltip-arrow {
  background-color: #f00;
}
Copy after login

Additionally, for Bootstrap 4, use the following CSS for tooltips:

.bs-tooltip-auto[x-placement^=bottom] .arrow::before,
.bs-tooltip-bottom .arrow::before {
  border-bottom-color: #f00; /* Red */
}
Copy after login

The above is the detailed content of How Can I Change the Color of Bootstrap Tooltips?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template