I'm defining PNG icons for use in buttons in CSS. How can I define .icon-test without hardcoding both height and width?
I'd like to define only one of them, and let the other one be inferred automatically, without having to manually care about the aspect ratio.
.icon {
display: inline-block;
}
.icon-test {
background-image: url(https://via.placeholder.com/32x15);
width: 2em;
height: 2em;
}
.button {
background-color: black;
color: white;
padding: 0.2em 1em;
display: flex;
align-items: center;
width: 8em;
justify-content: space-between;
}
<a class="button"><i class="icon icon-test"></i> BUTTON</a>
Note: What's the standard way to do this, in order to import a pack of icons, easily available with CSS classes e.g. <span class="icon icon-ok"></span>?