简体   繁体   English

CSS代码在Mac浏览器上运行但在Windows浏览器上运行?

[英]CSS Code working on Mac browsers but not on Windows browsers?

I have the following CSS: 我有以下CSS:

font-family: 'HelveticaNeue-UltraLight', 'Helvetica Neue UltraLight', 'Helvetica Neue', Arial, Helvetica, sans-serif; font-weight: 100; letter-spacing: 1px; }

It works on all Mac browsers (Chrome, Safari) But I opened my project on Chrome and Internet explorer on Windows, it displays the font as bold rather than light. 它适用于所有Mac浏览器(Chrome,Safari)但是我在Windows上的Chrome和Internet Explorer上打开了我的项目,它将字体显示为粗体而不是光。 I'm not sure how to fix this but I need the design to work cross platform with the design that appears on mac. 我不知道如何解决这个问题,但我需要设计与mac上出现的设计交叉平台。

Thanks in advance. 提前致谢。

Edit: I've tried using arial but arial doesn't become light on both mac and windows. 编辑:我尝试过使用arial但是arial在mac windows上都不会变亮。

The font you see on Windows is not bold, it is just regular Arial. 您在Windows上看到的字体不是粗体,它只是常规的Arial。

In almost all Windows systems, the first available font family among those listed in the font-family value is Arial. 在几乎所有Windows系统中, font-family值中列出的第一个可用字体系列是Arial。 Since Arial has no typeface of weight 100, or of any weight less than 400, the normal (400) weight typeface is used instead, by the font matching algorithm . 由于Arial没有重量100的字体,或任何重量小于400的字体,因此通过字体匹配算法使用普通(400)重量字体。

Fonts in standard distributions of Windows generally lack typefaces with weight less than normal. Windows标准发行版中的字体通常缺少重量低于正常值的字体。 So to use lighter typefaces, you would need to use downloadable fonts (web fonts) via @font-face . 因此,要使用较轻的字体,您需要通过@font-face使用可下载的字体(网络字体)。 See eg Is @font-face usable now? 请参阅例如Is @ font-face现在可用吗? (SO has many specific questions on using @font-face , check them if you run into specific problems with it). (对于使用@font-face有很多具体问题,如果遇到特定问题,请检查它们)。

The font-family property inform the browser that it's needed to use that font. font-family属性通知浏览器需要使用该字体。 If there is no path for it, it will check if the system have that one. 如果没有路径,它将检查系统是否具有该路径。

In order to be able to have a font that will work on all systems, you need to use the @font-face property. 为了能够使用适用于所有系统的字体,您需要使用@ font-face属性。

This last one will allow you to specify path for all the format font, that most of the browsers will download to display it correctly. 最后一个将允许您指定所有格式字体的路径,大多数浏览器将下载以正确显示它。 (For your information all recent browser support it) (为了您的信息,所有最近的浏览器支持它)

@font-face {
    font-family: 'myFont';
    src: url('myFont.eot');
    src: url('myFont.eot?#iefix') format('embedded-opentype'),
         url('myFont.woff') format('woff'),
         url('myFont.ttf') format('truetype'),
         url('myFont.svg#myFont') format('svg');
    font-weight: normal;
    font-style: normal;
}

If you want more information about that property you can check the reference here: 如果您想了解有关该属性的更多信息,可以在此处查看参考:

http://www.w3schools.com/cssref/css3_pr_font-face_rule.asp http://www.w3schools.com/cssref/css3_pr_font-face_rule.asp

Unfortunetly in your case the font HelveticaNeue is copyrighted, you need to buy the rights to be able to use it as a webfont. 不幸的是,在您的情况下,字体HelveticaNeue受版权保护,您需要购买权利才能将其用作webfont。

You can take a look here about pricing: http://www.fonts.com/search/all-fonts?searchtext=HelveticaNeue#product_top 您可以在这里查看价格: http//www.fonts.com/search/all-fonts? searchtext = HelveticaNeue #product_top

Also, if you have already the right and have one of the format that you wish to convert to a webfont, you can accomplish that here: 此外,如果您已经拥有权利并且拥有要转换为webfont的格式之一,则可以在此处完成此操作:

http://www.fontsquirrel.com/ http://www.fontsquirrel.com/

Finally, if you prefer you can use Google Fonts that will host the files for you, and you will just have a small script to insert inside your pages: 最后,如果您愿意,可以使用将为您托管文件的Google字体,您只需要在页面中插入一个小脚本:

http://www.google.com/fonts http://www.google.com/fonts

You can use web fonts (free or paid) as suggested by others, or just use a nice font stack that is likely to cover all bases. 您可以按照其他人的建议使用网络字体(免费或付费),或者只使用可能涵盖所有基础的漂亮字体堆栈。 CSS Tricks has a nice set of them: http://css-tricks.com/snippets/css/font-stacks/ CSS Tricks有很好的一套: http//css-tricks.com/snippets/css/font-stacks/

In terms of font weight, your CSS specifies a very light font weight: 在字体粗细方面,CSS指定了非常轻的字体粗细:

font-weight: 100;

So if you want to use bold Arial instead, you need to change that. 因此,如果您想使用粗体Arial,则需要更改它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM