<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<style>
.red-tooltip.tooltip-inner {
background-color:red;
}
.red-tooltip + .tooltip-inner {
background-color:red;
}
.red-tooltip > .tooltip-inner {
background-color:red;
}
.red-tooltip ~ .tooltip-inner {
background-color:red;
}
</style>
</head>
<body>
<span class="red-tooltip" data-toggle="tooltip" data-placement="top" title="Hello world">Hover me</span>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
<script>
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
</script>
</body>
</html>
I'm having trouble styling specific bootstrap tooltips. I have learned that I can universally style all the tooltips using these:
.tooltip-inner {
// Styles
}
.comment-tooltip .tooltip.bs-tooltip-auto[x-placement^=top] .arrow::before, .tooltip.bs-tooltip-top .arrow::before {
// Styles
}
Etc. for all the tooltip arrows. But how can I style a specific tooltip (i.e. one element's tooltip). For example let's say this is my HTML:
<span class="red-tooltip" data-toggle="tooltip" data-placement="top" title="Hello world">
Tooltip
</span>
I tried all the CSS combinators (shown below) but none of them seem to let me style ONLY tooltips with the class red-tooltip
.red-tooltip.tooltip-inner {
background-color:#ff0000;
}
.red-tooltip ~ .tooltip-inner {
background-color:#ff0000;
}
.red-tooltip > .tooltip-inner {
background-color:#ff0000;
}
.red-tooltip + .tooltip-inner {
background-color:#ff0000;
}
Any insight would be much appreciated!