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

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

问题描述

在asp.net上使用母版页工作在新的网站设计。页面标题是一个35像素高的菜单栏,其中包含作为无序列表呈现的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.

只是想知道是否有某种bug我不知道。

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示例位于顶部,u可以在选项卡下方看到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本身,增长了1px在chrome ...这对我来说很奇怪。

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.

推荐答案

重要的是要意识到,网页在不同的浏览器中总是呈现不同的。 Acheiving像素完美是徒劳的,现在我尝试向我的客户解释什么样的成本涉及,使每个浏览器呈现的网站完全相同。更经常的是,他们明白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天全站免登陆