Explore a straightforward Bootstrap 4 button featuring a fontawesome icon. If this button is situated in a container that happens to be slightly smaller than its default width, the icon will shift to the next line.
body {
padding: 20px;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="72101d1d06010600130232465c475c41">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="58283728283d2a76322b186976696e7669">[email protected]</a>/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4d2f2222393e393f2c3d0d796378637e">[email protected]</a>/dist/js/bootstrap.min.js" integrity="sha384-w1Q4orYjBQndcko6MimVbzY0tgp4pWB4lZ7lr30WKz0vr/aWKhXdBNmNb5D92v7s" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" integrity="sha384-DyZ88mC6Up2uqS4h/KRgHuoeGwBcD4Ng9SiP4dIRy0EXTlnuz47vAwmeGwVChigm" crossorigin="anonymous">
<a href="#" class="btn btn-light">One two three <i class="fa fa-arrow-right ml-1"></i></a>
<p class="mt-2">
When in a smaller container / window size:
</p>
<div class="mt-2" style="width: 140px;">
<a href="#" class="btn btn-light">One two three <i class="fa fa-arrow-right ml-1"></i></a>
</div>
Is there any method to prevent just the icon from moving to a new line (as depicted below)? In other words, can we ensure that the last word wraps onto the next line along with the icon?
https://i.sstatic.net/EMxtF.png
In my scenario, the solution of wrapping the last word and the icon within a span using white-space: nowrap;
doesn't seem feasible:
<span style="white-space: nowrap;">three <i class="fa fa-arrow-right ml-1"></i></span>
Could a pure CSS approach accomplish this task? Placing a
between the final word and the icon also does not yield the desired outcome.