how to use font awesome in own css?

后端 未结 4 1006
北荒
北荒 2021-02-05 13:04

I\'m using bootstrap and Font Awesome. In a custom css class I\'m working on I tried to include Font Awesome icons instead of using images. Here is my code before Font Awesome.<

4条回答
  •  梦谈多话
    2021-02-05 13:45

    Instructions for Drupal 8 / FontAwesome 5

    Create a YOUR_THEME_NAME_HERE.THEME file and place it in your themes directory (ie. your_site_name/themes/your_theme_name)

    Paste this into the file, it is PHP code to find the Search Block and change the value to the UNICODE for the FontAwesome icon. You can find other characters at this link https://fontawesome.com/cheatsheet.

    
    

    Open the CSS file of your theme (ie. your_site_name/themes/your_theme_name/css/styles.css) and then paste this in which will change all input submit text to FontAwesome. Not sure if this will work if you also want to add text in the input button though for just an icon it is fine.

    Make sure you import FontAwesome, add this at the top of the CSS file

    @import url('https://use.fontawesome.com/releases/v5.0.9/css/all.css');
    

    then add this in the CSS

    input#edit-submit {
        font-family: 'Font Awesome\ 5 Free';
        background-color: transparent;
        border: 0;  
    }
    

    FLUSH ALL CACHES AND IT SHOULD WORK FINE

    Add Google Font Effects

    If you are using Google Web Fonts as well you can add also add effects to the icon (see more here https://developers.google.com/fonts/docs/getting_started#enabling_font_effects_beta). You need to import a Google Web Font including the effect(s) you would like to use first in the CSS so it will be

    @import url('https://fonts.googleapis.com/css?family=Open+Sans:400,800&effect=3d-float');
    @import url('https://use.fontawesome.com/releases/v5.0.9/css/all.css');
    

    Then go back to your .THEME file and add the class for the 3D Float Effect so the code will now add a class to the input. There are different effects available. So just choose the effect you like, change the CSS for the font import and the change the value FONT-EFFECT-3D-FLOAT int the code below to font-effect-WHATEVER_EFFECT_HERE. Note effects are still in Beta and don't work in all browsers so read here before you try it https://developers.google.com/fonts/docs/getting_started#enabling_font_effects_beta

    
    

提交回复
热议问题