Font awesome icon and text in input submit button?
Asked Answered
A

3

33

I have a similar problem like here , i want to place font awesome icon into my submit button and also a text, it looks so: http://prntscr.com/608exx

Content of my input submit value is Buy now  

The icon is visible because i set on input field font-family: FontAwesome; my question is, how can i set on my text inside the button standard font family?

Acherman answered 2/2, 2015 at 18:16 Comment(0)
V
50

Try

<button type="submit" class="btn btn-default">
                    <i class="fa fa-shopping-cart"></i> Buy Now
                </button>
Voigt answered 2/2, 2015 at 18:27 Comment(0)
P
2

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

Proportional answered 19/6, 2018 at 12:20 Comment(0)
D
1

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;
}
Disburse answered 3/12, 2020 at 8:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.