I have a button which contains an icon, and the possibility to add a text. This text is optional and can be on the left- or on the right-handside. Depending on the position, the margin of the icon differs.
That means:
- if the icon is on the left-handside, it should have a margin-left of e.g. 5px
- if it's on the right-handside, margin-right should be e.g. 10px
- if there is no text at all, the icons margin should be e.g. 2px
Is there any way to style the icon without adding additional css (helper) classes like is-right
and without changing the markup? Maybe there is some pseudo selector, which could help here?
<button>
<span class="icon editIcon"></span>
Edit
</button>
<button>
Edit
<span class="icon editIcon"></span>
</button>
<button>
<span class="icon editIcon"></span>
</button>