The issue lies with the CSS selector currently being used. The selectors for the buttons are not matching correctly:
.app-btn:after:nth-child(1) { ... }
.app-btn:after:nth-child(2) { ... }
Since each button is a direct child of the parent div
, that selector doesn't work as intended.
A better approach would be to use nth-child
on the parent div (or possibly nth-of-type
) and then target the descendant app-btn
element:
.app:nth-child(1) > .app-btn:after { ... }
.app:nth-child(2) > .app-btn:after { ... }
See the following example for a demonstration:
.app > .app-btn {
font-size: 0px !important;
}
.app > .app-btn:after {
content: '+2500';
visibility: visible;
font-size: 15px !important;
}
.app:nth-child(1) > .app-btn:after {
content: "+18000";
}
.app:nth-child(2) > .app-btn:after {
content: "+14000";
}
<div class="app" data-url="#">
<button class="app-btn">CHANGE</button>
</div>
<div class="app" data-url="#">
<button class="app-btn">CHANGE</button>
</div>
<div class="app" data-url="#">
<button class="app-btn">CHANGE</button>
</div>