为不同操作系统使用不同的中文字体

请先阅读这篇文章:Web 中文字体应用指南

 

步骤一:在head中添加如下js,判断操作系统,并为html根节点添加相应操作系统class,注意需要引用jquery。

window.navigator.userAgent.indexOf('Windows') >= 0 ?
			jQuery(document.documentElement).addClass('Windows')
			:
			window.navigator.userAgent.indexOf('Macintosh') >= 0 ?
				jQuery(document.documentElement).addClass('Macintosh')
				:
				false
		;

 

步骤二:使用CSS选择器定义字体样式,为什么使用如下的字体定义,请阅读开头的文章。

.Windows body
{
    font-family: Helvetica, Tahoma, Arial, "Microsoft YaHei", "微软雅黑", SimSun, "宋体", Heiti, "黑体", sans-serif;
}

.Macintosh body
{
    font-family: Helvetica, Tahoma, Arial, STXihei, "华文细黑", sans-serif;
}


9 评论

  1. www.enterwing.com   •  

    就是不知道怎么设置继续阅读这样的文章。同样的主题,总感觉你用得很漂亮。

  2. mils   •  

    我就是随便看看

  3. 大埔   •  

    老大你的网站模板可以免费送吗?

    • 天屹   •     作者

      可以的啊,邮箱给我

  4. airo   •  

    你好,能给我一下你这个博客的wp模板吗?

    我的邮箱是airoot@139.com

    谢谢!

  5. leizai   •  

    看看!

天屹进行回复 取消回复

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>