4

I'm creating a specific function on a webpage that requires CSS overflow to be consistent between Chrome and Firefox (and ideally IE as well). When using common web fonts such as Arial there are no problems, but once I start using google web fonts, I see a difference in the CSS overflow.

Here's a demo: jsfiddle demo This is a fixed width div with some sample text. "Playball" is a google font.

#box {
   height: 160px;
   width: 200px;
   border: black 1px solid;    
   font-size: 2em;
   font-family: 'Playball', cursive;
   overflow-x: hidden;
   overflow-y: scroll;   
}

1) Screenshot of running jsfiddle demo on Firefox (L), and Chrome (R). Using "Arial", there is NO overflow-y in both browsers. FF(L) vs Chrome(R), ARIAL, NO overflow-y

2) Screenshot of running jsfiddle demo on Firefox (L), and Chrome (R). Using "Playball", there IS overflow-y in Firefox (see scrollbars) but NOT Chrome FF(L) vs Chrome(R), PLAYBALL, overflow-y

How can I make the CSS overflow consistent between Chrome and Firefox?

EDIT: Per Kamal's comment below, I've added a line height to both divs and indeed the scrollbar appearance is now consistence. However, another problem is on the third line, "jumped over the" fits in Chrome but only "jumped over" fits in FF. Any ideas? Latest fiddle.

Chrome L, FireFox R

fortuneRice
  • 4,214
  • 11
  • 43
  • 58

4 Answers4

4

Try changing the line height, as both screenshots, to me, look a little different in the spacing only, between the lines. EDIT : You should also try adjusting letter-spacing.

Kamal
  • 1,122
  • 11
  • 18
  • Most likely you need to do this – Bantros Apr 07 '12 at 19:54
  • Thanks, please see my edit for follow up question. (If I can award partial bounty points I will do so.) – fortuneRice Apr 07 '12 at 23:02
  • 1
    @fortuneRice - Partial bounty is not possible; however, you can "accept" one answer with the green checkbox and award the bounty to another. Thus, one person would get +50 and the other would get +15. – jamesmortensen Apr 08 '12 at 03:27
0

I found a way to make your overflow more consistent. Realizing even though you specify overflow: scroll, the scroll doesn't take any effect unless there is a reason for it to, so we have to force it a bit more manually.

I found part of the solution here: How can I prevent scroll bars from being hidden for OS X trackpad users in WebKit/Blink?

Also - I created a fiddle with the updated styles. So now even when the box is too small for the scrollbar to show up its still taking up space in the box in order to wrap your lines consistently.

Community
  • 1
  • 1
mikevoermans
  • 3,967
  • 22
  • 27
  • Thanks for your research. I'm looking for a way to get the CSS overflow consistent, instead of getting the scrollbars consistent. For my particular need, the scrollbar is just a visual indication of the CSS overflow. – fortuneRice Apr 07 '12 at 23:03
0

I think this is not solvable for each browser using different render engine, I mean browser elements like scroll-bar or checkbox (especially in Windows, you may test it on XP and 7, also in OSX and Linux)

Letter-spacing and Line-height, issue always occurred.

Cyril
  • 3
  • 4
0

Try to define line-height, letter-spacing and word-spacing in your css.

WolvDev
  • 3,182
  • 1
  • 17
  • 32