firefox vs webkit中的line

编程入门 行业动态 更新时间:2024-10-16 00:19:34
本文介绍了firefox vs webkit中的line-height 2px lower的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下css:

.btn_container { cursor: pointer; font-family: Tahoma,Verdana,Arial; font-size: 11px; padding: 0; width: auto; } .btn_center { background: blue; color: #FFFFFF !important; display: block; float: left; font-weight: bold; height: 32px; line-height: 32px; padding: 0 10px; }

在firefox中居中30行的行高,但32在webkit中。

line-height of 30 lines up center in firefox, but 32 in webkit.

我知道浏览器会呈现不同的东西,但我从来没有得到文本正确中心的问题。

I know browsers will render things differently, but i've never had a problem getting text to center properly.

在下面的例子中,你可以看到它在firefox中删除了一对px: jsfiddle/mstefanko/EGzEB/5/

In the following example you can see that it drops a couple px lower in firefox: jsfiddle/mstefanko/EGzEB/5/

推荐答案

我在过去做了大量的测试。我称之为文本摇摆。这不是你可以控制的东西。你可以做的最小化它是一个明确的行高(特别是一个在px)到每个文本元素。

I've done heavy testing of this in the past. I call it text jiggle. It's not something you can control. All you can do to minimize it is apply an explicit line-height (especially one in px) to every text element.

默认行高度变化一个宽裕度在不同的浏览器,和不同的字体家庭不同的字体大小。设置一个显式的行高地址。

The default line-height varies by a wide margin in different browsers, and for different font families at different font sizes. Setting an explicit line-height addresses that.

但是在此范围内,文本在行高空间中的确切位置会随浏览器到浏览器的变化而变化你做什么。对于font-size和line-height的某些组合,所有浏览器都匹配。例如,Arial在 font-size:11px 和 line-height:14px 和IE。但是将行高更改为13px或15px,浏览器之间的差异为1px。

But within that, the exact placement of the text within the line-height space will vary slightly browser-to-browser no matter what you do. For some combinations of font-size and line-height, all browsers match up. For instance, Arial at font-size:11px and line-height:14px renders the same in FF, Webkit, and IE. But change the line-height to 13px or 15px, and it varies by 1px browser-to-browser.

没有标准或定义的行为。它是这个特定font-family,font-size和line-height是如何由该操作系统上的浏览器呈现的结果。例如,Arial是一个相对一致的字体,通常不会变化超过1px,只要明确的line-height被定义,而Helvetica变化多达4到6个像素。

There's no standard or defined behavior for it. It's the result of how that particular font-family, font-size, and line-height happens to be rendered by the browser on that operating system. Arial, for instance, is a relatively consistent font, generally not varying by more than 1px as long as an explicit line-height is defined, while Helvetica varies by as many as 4 to 6 pixels.

更多推荐

firefox vs webkit中的line

本文发布于:2023-10-15 08:54:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1493822.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:firefox   webkit   line

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!