[英]top:1px calculated differently in chrome and FF
I was just recently debugging a site SEE HERE , Now if you scroll to the section immediately after the banner , the section with the accodion. 我刚刚调试一个网站在这里查看 ,现在如果你滚动到横幅后面的部分,该部分与accodion。
As you can see from the above image that the active tab has a top arrow that faces upwards. 从上图中可以看出,活动选项卡的顶部箭头朝上。 the css code is as follows:
css代码如下:
.hm-our-products-main-showcase .accordion-list-items > li.active > a {
font-weight: 900;
position: relative;
top: 1px;
background: url(../images/res/active-accordion-tab.jpg) no-repeat center bottom;
}
Notice how postion:relative
and top:1px
are used to cover the border that passes below, giving the impression that the active that has just an arrow and no bottom border. 注意
postion:relative
和top:1px
用于覆盖从下面经过的边框,给人的印象是只有一个箭头而没有底边框的活动。 Now this works fine in chrome but in FF there is a small problem the 1px does't quite get the arrow down enough to cover the border and the arrow on the active tab looks like below: 现在这在chrome中运行良好,但在FF中有一个小问题,1px不能完全让箭头向下覆盖边框,活动选项卡上的箭头如下所示:
See how the arrow does quite cover the bottom border. 看看箭头如何覆盖底部边框。 What is the solution to this ??
这是什么解决方案?
PS i can't used top:2px
because then in chrome things look a bit bad. PS我不能用
top:2px
因为那时在chrome中看起来有点不对劲。
Actually, this depends on OS-level and browser-level zoom. 实际上,这取决于操作系统级别和浏览器级别的缩放。 Looks like your font doesn't actually have bold glyphs, so to apply
font-weight: bold
, browsers are forced to generate bold glyphs based on normal glyphs and do this differently . 看起来您的字体实际上没有粗体字形,因此要应用
font-weight: bold
,浏览器会强制基于正常字形生成粗体字形并以不同方式执行此操作。
Given that your menu items are inline-block
s, you should add vertical-align: bottom
to them for their bottom edge's position to be unaffected by rasterization rounding errors and therefore predictable and consistent across browsers: 鉴于您的菜单项是
inline-block
,您应该为它们的下边缘位置添加vertical-align: bottom
,使其不受光栅化舍入错误的影响,因此可以跨浏览器进行预测和一致:
.hm-our-products-main-showcase .accordion-list-items > li {
vertical-align: bottom;
}
By the way, I would recommend you to get rid of shifting the active link itself by 1px
to bottom (ie remove position: relative; top: 1px;
from the active link's styles), and use an absolutely-positioned CSS-generated pseudoelement instead: 顺便说一句,我建议你摆脱将活动链接本身移动
1px
到底部(即移除position: relative; top: 1px;
从活动链接的样式),并使用绝对定位的CSS生成的伪元素代替:
.hm-our-products-main-showcase .accordion-list-items > li.active > a {
position: relative;
}
.hm-our-products-main-showcase .accordion-list-items > li.active > a:after {
background: url(active-accordion-tab.jpg) no-repeat;
content: '';
margin-left: -7px; /* Half the width to center the arrow. */
position: absolute;
left: 50%;
bottom: -1px; /* Compensating menu's border-bottom. */
width: 14px;
height: 8px;
}
Change your top:1px
to top:1.5px
it works perfectly fine on both browsers ie Chrome
and Firefox
. 改变你的
top:1px
到top:1.5px
它在两种浏览器上都可以正常工作,即Chrome
和Firefox
。
.hm-our-products-main-showcase .accordion-list-items > li.active > a {
font-weight: 900;
position: relative;
top: 1.5px;
background: url(../images/res/active-accordion-tab.jpg) no-repeat center bottom;
}
That is because it displays different different font size for different browser. 这是因为它为不同的浏览器显示不同的字体大小。 There is minor difference.
有细微的差别。
To solve this: 要解决这个问题:
Use: 使用:
.accordion-list-items > li.active {
font-weight: 900;
vertical-align: top;
}
And remove font-weight: 900;
并删除
font-weight: 900;
from .hm-our-products-main-showcase .accordion-list-items > li.active > a
来自
.hm-our-products-main-showcase .accordion-list-items > li.active > a
The font-weight property sets the weight, or thickness, of a font and is dependent either on available font faces within a font family or weights defined by the browser .
font-weight属性设置字体的权重或厚度,并且取决于字体系列中的可用字体面或浏览器定义的权重。
If a font has a bold ("700") or normal ("400") version as part of the font family, the browser will use that.
如果字体具有粗体(“700”)或普通(“400”)版本作为字体系列的一部分,则浏览器将使用该版本。 If those are not available, the browser will mimic its own bold or normal version of the font .
如果这些不可用, 浏览器将模仿其自己的粗体或普通版本的字体 。
you use display inline-block
you should add vertical-align:top
你使用display
inline-block
你应该添加vertical-align:top
add vertical-align: top;
add
vertical-align: top;
this class 这个班
.hm-our-products-main-showcase .accordion-list-items > li > a {
color: #000;
padding-bottom: 1.25em;
display: inline-block;
vertical-align: top;
}
Remove padding-bottom: 1.25em;
去除
padding-bottom: 1.25em;
from here 从这里
.hm-our-products-main-showcase .accordion-list-items > li > a {
color: #000;
padding-bottom: 1.25em;
display: inline-block;
}
and add it here, 并在这里添加,
.hm-our-products-main-showcase .accordion-list-items > li.active > a {
font-weight: 900;
position: relative;
top: 1px;
background: url(../images/res/active-accordion-tab.jpg) no-repeat center bottom;
padding-bottom: 1.25em;
}
this should solve the padding problem and make it look the same in both Chrome and Firefox. 这应解决填充问题,并使其在Chrome和Firefox中看起来都一样。
try this
.hm-our-products-main-showcase .accordion-list-items > li {
display: inline-block;
text-transform: uppercase;
vertical-align: top;
}
Give vertical-align: top;
给
vertical-align: top;
to your li element because you are using display: inline-block;
你的li元素,因为你使用
display: inline-block;
while using inline-block
we should align vertically to avoid this type of issues. 在使用
inline-block
我们应该垂直对齐以避免此类问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.