📜  如何在 html 中添加字体 otf 格式 - CSS 代码示例

📅  最后修改于: 2022-03-11 14:47:53.243000             🧑  作者: Mango

代码示例1
/*default version*/
@font-face {
    font-family: 'lovelyFont';
    src: url('fonts/lovely_font.eot'); 
    src: 
        local('Lovely Font'),
        local('Lovely-Font'),
        url('fonts/lovely_font.otf') 
        format('opentype');
}
/*bold version*/
@font-face {
    font-family: 'lovelyFont';
    src: url('fonts/lovely_font_bold.eot'); 
    src: 
        local('Lovely Font Bold'),
        local('Lovely-Font-Bold'),
        url('fonts/lovely_font_bold.otf') 
        format('opentype');
    font-weight: bold;
}
/*container element*/
div { font-family: 'lovelyFont', sans-serif; }
/*span elements inside the container div*/
span { font-weight: bold; }