Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

1 pixel line height difference between Firefox and Chrome

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.

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.

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

EDIT:

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; } 

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

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.

alt text

EDIT:

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.

like image 254
stephen776 Avatar asked Dec 14 '10 13:12

stephen776


People also ask

How does Firefox compare to Chrome?

Firefox is a more private and secure browser than Chrome, but Chrome is faster and contains more features. Is Firefox Safer Than Chrome? Both browsers are safe, but Firefox's tracking protection is more comprehensive than Chrome's.

Does Firefox run better than Chrome?

That being said, Mozilla Firefox wins the race in this comparison of Chrome vs. Firefox. Although Chrome has excellent features, it does not have features that the user could engage more with. However, they can add extensions to make it useful.

What is standard line height pixels?

If your font size is 10px, your line height will be 3px, 5px, and 11px respectively. Alternatively, you can specify the “normal” keyword. This keyword specifies the use of the browser default. This value is usually around 1.2, depending on what browser the viewer is using.


1 Answers

None of these answers solve the problem.

Set:

line-height: 1; padding-top: 2px; 

Because webkit & mozilla rendering engines implement line height differently do not use this it to manipulate measurement for single line items.

For items like menus, buttons and especially really small notification bubbles, reset the line-height to normal and use padding or margins to make them behave the same.

Here's a JSFiddle illustrating this issue: http://jsfiddle.net/mahalie/BSMZe/6/

like image 90
mahalie Avatar answered Oct 14 '22 17:10

mahalie