提高 css3 文本旋转质量

发布于 2024-12-22 06:50:32 字数 217 浏览 4 评论 0原文

我使用 CSS3 创建了一系列圆形选项卡。然后我旋转了这些选项卡,但文本的质量(Windows - Chrome)很差,并且在转换时也“变暗/模糊”。有哪些替代方案?我是否正确应用了 CSS?我最好旋转选项卡并保持文本水平吗?

http://jsfiddle.net/jeepstone/9eGt3/

I've created a series of rounded tabs using CSS3. I've then rotated these tabs, but the quality of the text (Windows - Chrome) is poor and also 'dims/blurs' on transition. What are the alternatives? Have I applied my CSS correctly? Would I be better to rotate the tabs and keep the text horizontal?

http://jsfiddle.net/jeepstone/9eGt3/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伴梦长久 2024-12-29 06:50:32

Chrome

Chrome 默认不启用抗锯齿功能。但是您可以将此 CSS 属性添加到您的元素中以启用它:

transform: translate3d(0,0,0);

这将强制浏览器使用其硬件加速来计算变换,这将添加一些抗锯齿功能作为奖励。

通过将 -webkit-backface-visibity 设置为 hidden 也可以应用相同的效果:

-webkit-backface-visibility: hidden;

这是更新的 jsfiddle(在 Chrome 中测试)

http://jsfiddle.net/9eGt3/6/

Firefox

Firefox 默认启用抗锯齿功能,因此不需要使用任何transform3d hack必需的,但抗锯齿算法的质量因浏览器版本而异。以下是一些比较图像:

Firefox 5 Firefox 9 Chrome

分别是 Firefox 5、Firefox 9 和 Chrome。

这里最好的选择是调整字体,使其对抗锯齿算法更加友好。在这种情况下,选择更粗更大的字体可能会有所帮助。

Chrome

Chrome doesn't enable anti-aliasing by default. But you can add this CSS property to your elements in order to enable it:

transform: translate3d(0,0,0);

This will force the browser to use its hardware acceleration to calculate the transforms, which will add some anti-aliasing as a bonus.

The same effect could also be applied by setting the -webkit-backface-visibity to hidden:

-webkit-backface-visibility: hidden;

Here is your updated jsfiddle (tested in Chrome)

http://jsfiddle.net/9eGt3/6/

Firefox

Firefox enables anti-aliasing by default so no transform3d hack is required, but the quality of the anti-aliasign algorithm varies among the browser version. Here are some comparison images:

Firefox 5 Firefox 9 Chrome

Those are Firefox 5, Firefox 9 and Chrome respectively.

Your best bet here is to tweak your font in order to make it more friendly to the anti-aliasing algorithm. In this case, choosing a bolder and bigger font might help.

寄与心 2024-12-29 06:50:32

正如我提到的,使用 javascript 可能会使过渡更加平滑,而不会破坏文本或边框。用这个替换 CSS 过渡似乎有很大帮助。这是使用 jQuery - 当然使用您选择的工具:

// <li> needs position:relative; in the CSS
$('li').hover(
    function(){
        $(this).stop().animate({'top':'-10px'});
    },function(){
        $(this).stop().animate({'top':'0'});
    }
);

http://jsfiddle.net/9eGt3/5/

我不太幸运能够经常使用 CSS3,所以这不是我的专业领域 - 但不幸的是我不得不删除现有的 CSS 悬停过渡才能让它工作。您可以使用 JavaScript 检测技术来回退到 CSS 转换,例如将 class="js-enabled" 添加到 body 标记(当然使用 js)并在 CSS 选择器中使用它。

除此之外,我认为除非您想使用图像(呸)或者再等几年直到浏览器可以更好地处理这些东西(grr),否则您已经筋疲力尽了。不要将此视为福音,有人可能会为您提供解决方案 - 但我想我至少会提供一个解决方法。

As I alluded to, using javascript might make the transition smoother, without disrupting the text or borders. Replacing the CSS transitions with this seemed to help greatly. This is using jQuery - use the tool of your choice of course:

// <li> needs position:relative; in the CSS
$('li').hover(
    function(){
        $(this).stop().animate({'top':'-10px'});
    },function(){
        $(this).stop().animate({'top':'0'});
    }
);

http://jsfiddle.net/9eGt3/5/

I'm not lucky enough to be able to use CSS3 very often, so this is not an area of expertise for me - but I unfortunately had to remove the existing CSS hover transitions to get it to work. You might use a javascript detection technique to fall back to CSS transtitions, like by adding class="js-enabled" to the body tag (with js of course) and using that in your CSS selector.

Outside of that, I think you're out of gas unless you want to use images (bah) or wait a few more years until browsers can handle this stuff a little better (grr). Don't take this as gospel, someone might have a solution for you - but I thought I'd at least offer a workaround.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文