Firefox 和 Chrome 之间的 1 像素线高差 [英] 1 pixel line height difference between Firefox and Chrome

查看:29
本文介绍了Firefox 和 Chrome 之间的 1 像素线高差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在使用母版页在 asp.net 中设计新网站.页面的标题是一个 35px 高的菜单栏",其中包含一个呈现为无序列表的 asp 菜单控件.

Working on a new site design in asp.net with master pages. Header of the page is a 35px tall "menu bar" which contains an asp menu control rendered as an unordered list.

所选菜单项的样式具有不同的彩色背景和左右两侧 2px 的边框.所选菜单项的底部应该与菜单栏的底部对齐,这样所选的标签"看起来就好像流入下面的内容.在 Firefox 和 IE 中看起来不错,但在 chrome 中,标签"似乎比菜单栏底部高 1 个像素.

The selected menu item is styled with a differenct colored background and 2px border around the left top and right sides. The bottom of the selected menu item should line up with the bottom of the menu bar so the selected "tab" looks as if it flows into the content beneath. Looks fine in firefox and IE but in chrome the "tab" seems to be 1 pixel higher than the bottom of the menu bar.

只是想知道是否有某种我不知道的错误.

Just wondering if there is some sort of bug I dont know about.

我意识到您很可能需要代码来帮助解决这个问题,所以请尽快发布 css.

I realize that you will most likely need code to help with this problem so ill post up the css as soon as possible.

这是菜单的 css...

here is the css for the menu...

div.hideSkiplink
{     
    width:40%;
    float:right;
    height:35px;
}

div.menu
{
    padding: 0px 0px 0px 0px;
    display:inline;
}

div.menu ul
{
    list-style: none;
}

div.menu ul li
{
    margin:0px 4px 0px 0px;
}

div.menu ul li a, div.menu ul li a:visited
{
  color: #ffffff;
  display: block;
  margin-top:0px;
  line-height: 17px;
  padding: 1px 20px;
  text-decoration: none;
  white-space: nowrap;
}

div.menu ul li a:hover
{
  color: #ffffff;
  text-decoration: none;
  border-top: 1px solid #fff;
  border-right: 1px solid #fff;
  border-bottom: none;
  border-left: 1px solid #fff;
}




div.menu ul li a:active
{
 background:#ffffff !important;
 border-top:2px solid #a10000;
 border-right:2px solid #a10000;
 border-bottom: none;
 border-left:2px solid #a10000;
 color: #000000 !important;
 font-weight:bold;

}


div.menu ul a.selected
{
  color: #000000 !important;
  font-weight:bold;
}

div.menu ul li.selected
{
 background:#ffffff !important;
 border-top:2px solid #a10000;
 border-right:2px solid #a10000;
 border-bottom: none;
 border-left:2px solid #a10000;
}

div.menu ul li.selected a:hover
{
  border: none;
}

选择的类通过 jquery 添加到 li 和 a 元素中...

The selected classes are added to the li and a elements via jquery...

这是问题的截图...chrome 示例位于顶部,您可以在选项卡下方看到 1px 的红色边框.底部是 Firefox 图像,一切正常.

Here is a screenshot of the problem... The chrome example is on the top and u can see 1px of red border below the tab. On the bottom is the firefox image where everything looks OK.

在玩了更多之后,我发现它实际上是标题"div 本身在 chrome 中增长了 1px ......这对我来说似乎很奇怪.

After playing around with this a bit more, I have discovered that it is actually the "header" div itself that is growing by 1px in chrome... This seems very strange to me.

推荐答案

重要的是要认识到网页在不同浏览器中的呈现方式总是不同的.实现像素完美是徒劳的,现在我试图向我的客户解释使每个浏览器呈现完全相同的网站需要什么样的成本.现在更多的是,他们明白 IE6 和 FF4 永远不会以相同的方式呈现任何页面.我们必须努力让我们的客户了解并接受网络的动态.

It's important to realize that web pages will always render differently in different browsers. Acheiving pixel perfection is futile, and nowadays I try to explain to my clients what kind of cost is involved to make every browser render the site exactly alike. More often now, they understand that IE6 and FF4 won't ever render any page the same way. We must try to make our clients understand and embrace the dynamics of the web.

渐进增强和优雅降级.和平.

Progressive enhancement and graceful degradation. Peace.

这篇关于Firefox 和 Chrome 之间的 1 像素线高差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆