简体   繁体   中英

How to add fonts to classes

Hey can anyone fill me in on how to add fonts to HTML classes? I was watching a tutorial and that part skipped and I'm confused exactly what he did. There was a box class with different elements in it and he was trying to add font styling before it skipped.

This is the HTML and CSS, excluding the <head> and <body> tags:

 .body { Background-color: red; } .box { Width: 174px; Height: 250px; Background: yellow; Width: 25px Padding:20px; } .true { Background-color: brown; } .true2 { Background-color: green }
 <Div class="box true"> this is an example</Div> <Div class="box true2> parenthesis</Div>

Use the font-family styling in your classes:

Example:

body {
    font-family: Arial, sans-serif;
}

You can also add custom fonts like this:

@font-face {
    font-family: myFirstFont;
    src: url(sansation_light.woff);
}

And then just juse font-family: myFirstFont; whenever you need it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM