Font awesome icon and text in input submit button?
In order to do this whilst retaining the <input>
element, you must put the Font Awesome glyph outside of the <input>
and then simply position it on top.
<span><i class="fas fa-shopping-cart glyph"></i></span>
<input type="button" class="button" value="Basket" />
Then simply add some CSS to make the whole button clickable.
.glyph{
position: relative;
left: 35px;
pointer-events: none; //this makes the glyph clickable as part of the input
}
.button{
width: 100px;
height: 100px;
padding-left: 20px;
}
JSFiddle
Try
<button type="submit" class="btn btn-default">
<i class="fa fa-shopping-cart"></i> Buy Now
</button>
It is quite easy to change it only via CSS. Just need to pick up all types of tags attributes.
For example:
for buttons: input, [type="button"], [type="reset"], [type="submit"] for text: input, [type="text"] and etc...
input, [type="button"], [type="reset"], [type="submit"] {
-webkit-appearance: button;
background-color: #EF2B76;
padding-left: 2rem;
padding-right: 2rem;
cursor: pointer;
color: white;
}
input, [type="text"] {
background-color: white;
padding-left: 2rem;
padding-right: 2rem;
cursor: pointer;
color: white;
}