javascript 在 IE 中旋转文本,不会变得难看

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4899442/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 15:16:36  来源:igfitidea点击:

Rotate text in IE, without it getting ugly

javascriptjqueryinternet-explorercss

提问by RemiX

I'd like to rotate a text by 90 degrees counter-clockwise. Firefox and Chrome are no problem, using:

我想将文本逆时针旋转 90 度。Firefox 和 Chrome 没有问题,使用:

-webkit-transform-origin: top left;
-webkit-transform: rotate(-90deg);
-moz-transform-origin: top left;
-moz-transform: rotate(-90deg);

For Internet Explorer, it should be this line, as far as I know:

对于 Internet Explorer,据我所知,应该是这一行:

filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);

(The other method, writing-mode, can only rotate text clockwise 90 degrees).

(另一种方法,writing-mode,只能将文本顺时针旋转 90 度)。

However, in IE the rotated text looks like a badly scaled image on its side (comparison below).

然而,在 IE 中,旋转的文本在其侧面看起来像一个严重缩放的图像(下面的比较)。

Firefox/ChromeFirefox / Chrome -- vs -- Internet Explorer: Internet Explorer

火狐/ChromeFirefox / Chrome -- vs -- Internet Explorer: IE浏览器

Is there any way that Internet Explorer can rotate the text in a more elegant way (possibly Javascript/jQuery)? I've been Googling, but I can only find more references to this method...

有什么办法可以让 Internet Explorer 以更优雅的方式(可能是 Javascript/jQuery)旋转文本?我一直在谷歌搜索,但我只能找到更多关于这种方法的参考......

采纳答案by swishmiller

The RenderEngine of IE is awful... I would try to work with background images. Maybe a Font Replacementlike Cufonwould do a better Job. Cufon generates Images of your Text. Works good in IE as far as i know.

IE 的 RenderEngine 很糟糕……我会尝试处理背景图像。也许像Cufon这样的字体替换会做得更好。Cufon 生成文本图像。据我所知,在 IE 中运行良好。

回答by Dawson

It is Def the text rendering engine in IE; however, it's doable.

它是 IE 中的文本渲染引擎;然而,这是可行的。

filter:requires the element to have layout(ie. zoom). You can beat the rendering problem (most of the time), by giving the element a background color. Try the following on your example:

过滤器:要求元素具有布局(即缩放)。您可以通过为元素提供背景颜色来解决渲染问题(大多数情况下)。在您的示例中尝试以下操作:

zoom:1;
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
background-color:white;

回答by Barrie Reader

I would suggest either Google Fonts API or Cufon (as @swishmiller said), ordisabling Anti-Aliasing (ClearType) in IE so the fonts always look unsmoothed (is that a word)?

我建议使用 Google Fonts API 或 Cufon(如@swishmiller 所说),或者在 IE 中禁用抗锯齿(ClearType),这样字体总是看起来不平滑(这是一个词)?

Google Font API: http://code.google.com/webfonts

谷歌字体 API:http: //code.google.com/webfonts

Cufon: http://cufon.shoqolate.com/generate/

Cufon:http: //cufon.shoqolate.com/generate/

Disable ClearType:

禁用清除类型:

    /* This will force IE into thinking there is a filter actually doing something, so it'll disable ClearType */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
    filter:progid:DXImageTransform.Microsoft.Alpha(opacity=100);

[edit]I should mention that I've not tried the Google Font API fix...

[编辑]我应该提到我没有尝试过谷歌字体 API 修复......