How can I apply padding to a button only if it contains an external icon? If the button has an external icon, I want to give it padding-right: 30px
(example). However, if there is no external icon present, then the button should not have the 30px padding. Currently, I am facing the issue of the 30px padding-right still being applied even when there is no external icon present (Example).
Is there a way to toggle the CSS based on the presence of an external icon?
Below is the HTML and CSS:
.btn {
border-radius: 3px;
border: none;
height: 45px;
font-weight: bold;
font-size: 18px;
background: #FFFFF;
color: #515151;
margin-top: 19px;
padding-top: 12px;
border: solid #FFFFFF 1px;
}
<a href="......." title="Hello World" class="btn btn-default" role="button" target="_blank">
Button Title
<svg class="svg-inline--fa fa-external-link fa-w-16 pull-right" title="external link icon" aria-labelledby="svg-inline--fa-title-u1BaVqD2mZ2F" data-prefix="far" data-icon="external-link" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg="">
<title id="svg-inline--fa-title-u1BaVqD2mZ2F">external link icon</title>
</svg>
<!-- <i class="far fa-external-link pull-right" title="external link icon"></i> -->
</a>