【问题标题】:Want to change the font of text想改变文字的字体
【发布时间】:2015-01-12 14:21:54
【问题描述】:

我目前有这个代码:

 <div class="box" style="margin-bottom: 10px; max-width: 100%;">     
 <div class="clearfix"style="padding: 10px 10px 0 10px; background: #f3f3f3; text-align: center;">                <span style="font-size: 1.17em; color: #000000;">LINGERIE</span><br/>     
 <p style="color: #000000;">&nbsp;</p>
 <span style="color: #000000;">&diams;Lingerie Sets &nbsp; &nbsp;&diams;Hosiery &nbsp; &nbsp;                    &diams;Plus Size </span><span style="font-size: 12px;">&nbsp; &nbsp;</span></div>
</div>         

我不确定在哪里添加我的字体?我想使用蒙特塞拉特,这是我菜单的当前字体,等等。提前致谢

【问题讨论】:

  • 内联 CSS 是不好的做法。您应该创建一个单独的 CSS 文件并将其包含在 HTML 文档的 head 中,并带有 link 元素。
  • 为什么这是“不好的做法”谢谢
  • 因为当您有多个 HTML 文件时,您会发现很难维护您的样式。使用 CSS,您可以简单地 div { margin-bottom: 10px; } 将该样式应用于 all div 元素。使用内联 CSS,您每次添加示例 div 元素时都必须重新编写。

标签: css text fonts webfonts


【解决方案1】:

你可以用 CSS 做到这一点:

font-family: Montserrat;

例如:

<span style="color: #000000;font-family: Montserrat;">&diams;Lingerie Sets ...</span>

来源:http://www.w3schools.com/cssref/pr_font_font-family.asp

【讨论】:

    【解决方案2】:

    this link 中,您有关于如何使用蒙特塞拉特字体的完整说明:

    1) 将此代码添加到您的网站(将其添加到您的 html 页面的 &lt;head&gt; 部分):

    <link href='http://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
    

    2) 创建一个新文件,即 styles.css 并将其添加到您的 &lt;head&gt; 部分(或重复使用旧文件)。然后将你的字体整合到你的 CSS 中:

    font-family: 'Montserrat', sans-serif;
    

    例子:

    h1 { 
        font-family: ‘Metrophobic’, Arial, serif; 
        font-weight: 400; 
    }
    

    【讨论】:

      猜你喜欢
      • 2020-06-09
      • 2010-09-18
      • 2015-11-01
      • 2020-10-14
      • 1970-01-01
      • 1970-01-01
      • 2018-09-19
      • 1970-01-01
      • 2011-12-01
      相关资源
      最近更新 更多