首页 文章

Font-Family在相同的 Headers 上使用不同的字体

提问于
浏览
0

加载Google字体(Open sans)时,如下所示:

<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,400italic,700' rel='stylesheet' type='text/css'>

并在CSS中使用它像这样:

font-family: 'Open Sans',sans-serif !important;

在不同的页面上,但页面加载相同的 Headers ,css等:

第1页:font-family:' Open Sans ',sans-serif!important;

第2页:font-family:'Open Sans', sans-serif !important;

在这两个页面上都加载了Google-font和css .

有人知道可能导致这种情况的原因吗?

1 回答

  • 0

    尝试使CSS规则更具体 . 我看到你正在使用 !important 标签,所以你可能会覆盖框架或其他地方的现有规则 .

    例如,如果你're trying to give a font to all headers, you probably have other divs surrounding them. Let' s说div被称为 content

    body .content .h1, body .content .h2 {
        font-family: 'Open Sans',sans-serif !important;
    }
    

    最好的办法就是看看为什么你的款式没有造型 . 除非完全必要,否则您应该尝试在任何地方使用 !important 规则 .

相关问题