How do I add a Font Awesome icon to input field?

前端 未结 8 1733
野性不改
野性不改 2020-11-28 01:36

How do I use the search icon included in Font Awesome for input? I have a search feature on my site (based on PHPmotion), that I want to use for the search.

Here\'s

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 02:24

    Similar to the top answer, I used the unicode character in the value= section of the HTML and called FontAwesome as the font family on that input element. The only thing I'll add that the top answer doesn't cover is that because my value element also had text inside it after the icon, changing the font family to FontAwesome made the regular text look bad. The solution was simply to change the CSS to include fallback fonts:

    
    
    font-family: FontAwesome, Roboto, sans-serif;
    

    This way, FontAwesome will grab the icon, but all non-icon text will have the desired font applied.

提交回复
热议问题