Css 如何仅对特定段落类使用Google Webfont loader?
我一直在用漂亮的字体显示我网站的部分内容。我这部分做得很好,我所有的Css 如何仅对特定段落类使用Google Webfont loader?,css,webfonts,google-webfonts,Css,Webfonts,Google Webfonts,我一直在用漂亮的字体显示我网站的部分内容。我这部分做得很好,我所有的都用我想要的字体显示。但是,我只希望一些类的(即)用webfonts显示,其余的则用常规字体显示(即不是Google webfonts)。 对我来说,实现这一目标的最佳方式是什么?目前,我正在使用这个 <script type="text/javascript"> WebFontConfig = { google: { families: [ 'McLaren' ] } };
都用我想要的字体显示。但是,我只希望一些类的(即
)用webfonts显示,其余的则用常规字体显示(即不是Google webfonts)。
对我来说,实现这一目标的最佳方式是什么?目前,我正在使用这个
<script type="text/javascript">
WebFontConfig = {
google: { families: [ 'McLaren' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
</script>
<style type="text/css">
.wf-loading p.someclass {
font-family: serif
}
.wf-inactive p.someclass {
font-family: cursive
}
.wf-active p.someclass {
font-family: 'McLaren', cursive
}
</style>
WebFontConfig={
谷歌:{families:['McLaren']}
};
(功能(){
var wf=document.createElement('script');
wf.src=('https:'==document.location.protocol?'https':'http')+
“://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js”;
wf.type='text/javascript';
wf.async='true';
var s=document.getElementsByTagName('script')[0];
s、 parentNode.insertBefore(wf,s);
})();
.wf加载p.someclass{
字体系列:衬线
}
.wf非活动p.someclass{
字体系列:草书
}
.wf活动p.someclass{
字体系列:“迈凯轮”,草书
}
整个页面的所有
都以“迈凯轮”字体显示。我肯定我在用CSS选择器做一些愚蠢的事情,但我不太确定是什么
任何帮助都将不胜感激。谢谢首先,你不一定需要js版的谷歌字体,我刚刚通过css链接了它们,没有加载问题。其次,有人需要查看您实际html的主体,但您不需要p前缀,只需将字体添加到类。someclass{font-family:cursizve;}
也如我所说,在客户端使用css伪类工作得更好、更轻谢谢,我刚刚删除了p,效果很好。我想知道为什么我一开始没有试一下…是的,很抱歉,迟来的回复没有打开,有些浏览器很奇怪,有些css语法很奇怪,你只需要玩一下就可以了。