I'm positioning an icon inside a button. To align the icon to the right of the button, I'm using float: right
on the icon. But as you'll see, this causes the icon to overflow on Firefox, so I need another solution.
float: left
to the text isn't an optionHere's the Sass
for the icon and button:
.icon-icomoon
font-family: 'icomoon' !important
speak: none
font-style: normal
font-weight: normal
font-variant: normal
text-transform: none
line-height: 1
-webkit-font-smoothing: antialiased
-moz-osx-font-smoothing: grayscale
.icon-arrow-right:before
content: "\e910"
.btn
border-radius: 0
padding: 20px 40px
font-weight: 600
font-family: $fontSansSerif
font-size: 1.9em
span.icon-arrow-right
float: right
font-size: 40px
.mobile-and-tablet-only
display: none
@media screen and (max-width: $mediaBreakpointTablet)
display: block
.desktop-only
display: none
@media screen and (min-width: $mediaBreakpointTablet+1)
display: block
Here's the HTML
for the button:
<a href="#" class="btn btn-success">
<span class="desktop-only">
Let's make something awesome together
<span class="icon-icomoon icon-arrow-right"></span>
</span>
<span class="mobile-and-tablet-only">
Let's work together
<span class="icon-icomoon icon-arrow-right"></span>
</span>
</a>
Here's what it looks like in the browser on Chrome:
And here's what it looks like on Firefox. As you can see, the width of the text is at 100% which is causing the icon to overflow:
Try giving the a.btn
position:relative
and then positioning the span.icon-arrow-right
absolutely (position: absolute
). Then you can give the arrow icon any desired position by adding right: 3%; top: 33%
to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With