I need to customize Bootstrap 5 .text-success
color
for better contrast on my custom .bg-lvlN
classes. Here is how I have defined them:
.bg-lvl1 {
background-color: #303333;
}
.bg-lvl2 {
background-color: #222424;
}
/* Overriding .text-success color */
.bg-lvl1 .text-success {
color: #00d750 !important;
}
.bg-lvl2 .text-success {
color: #00c74a !important;
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6f0d00001b1c1b1b1e0e171b06146344514e5347584f44">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="bg-lvl2">
<!-- The text inside this span should have color #00c74a -->
<span class="text-success">Green</span>
<div class="bg-lvl1">
<!-- The text inside this span should have color #00d750, but currently it's #00c74a -->
<span class="text-success" id="nested">Green</span>
</div>
</div>
Unfortunately, the .bg-lvl2 .text-success
rule takes precedence over .bg-lvl1 .text-success
rule for the #nested
span
.
How can I make the .bg-lvl1 .text-success
style apply to #nested
span
? Or is there a different approach to achieve the desired text color?