5

Context

I did a pure CSS tooltip with pseudo-element :before and :after for the arrow.

The rendering is different from Chrome 16 to Firefox 9 and 10.

You see what's wrong?

Chrome screenshot

enter image description here

Firefox screenshot

enter image description here

Demo

http://jsfiddle.net/wDff8/ reproduces the same issue.

Code

:

<span class="tooltip">Déposez votre fichier dans ce dossier</span>

:

span.tooltip {
  display: inline-block;
  background: #eee;
  margin-left: 20px;
  padding: 0 10px;
  color: #111;
  border-radius: 2px;
  border-top: 1px solid #bbb;
  border-right: 1px solid #bbb;
  border-bottom: 1px solid #bbb;
  line-height: 1.5;
  position: relative;
}

span.tooltip:before {
  content:"";
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 10px;
  border-color: transparent #eee transparent transparent;
  left: -18px;
  top: -1px;
  z-index: 1;
}

span.tooltip:after {
  content:"";
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 11px;
  border-color: transparent #bbb transparent transparent;
  left: -21px;
  top: -2px;
  z-index: 0;
}

body {
    font-family: Georgia;
    font-size: 12px;
    letter-spacing: 1px;
}
Community
  • 1
  • 1
GG.
  • 21,083
  • 14
  • 84
  • 130
  • In Firefox 9 and Chrome 16 on the Mac, I don’t see the issue in your screenshots (i.e. the thicker arrow point). Which versions are you using? – Paul D. Waite Feb 01 '12 at 10:08
  • Your html and CSS don't match your screenshot (the icon from the screenshot is missing). Are you sure you pasted the correct version of your problematic code? – Mr Lister Feb 01 '12 at 10:12
  • 1
    @PaulD.Waite: Chrome 16 and Fx 9/10 on Windows. http://jsfiddle.net/wDff8/ reproduces the same issue. – GG. Feb 01 '12 at 10:14
  • @MrLister: I added the CSS for the body. – GG. Feb 01 '12 at 10:15
  • @GG. cheers for the Fiddle, great stuff. Hmm — still looks alright to me on the Mac, although if I tweak the `border-width` values I can get some thickening. You’re not zoomed in in Firefox are you? Zooming in seems to produce the effect from your Firefox screenshot. – Paul D. Waite Feb 01 '12 at 10:26
  • I looked at the Mac of a colleague: the rendering is different with Chrome, Firefox and Safari... Chrome Mac: space of 1px between the arrow and the box. Firefox and Safari : the arrow exceeds the bottom of 1px. – GG. Feb 01 '12 at 10:27
  • I removed a few pixels, which corrected the rendering on Firefox without changing the rendering on Chrome... It looks good. Can you look at http://jsfiddle.net/wDff8/1/? – GG. Feb 01 '12 at 10:35

2 Answers2

7

May be Instead of transparent you have to write this rgba(238,238,238,0)in your css check this for more

CSS Transparent Border Problem In Firefox 4?

Community
  • 1
  • 1
sandeep
  • 91,313
  • 23
  • 137
  • 155
  • Great it works! rgba(0,0,0,0) for the content of the arrow and rgba(238,238,238,0) for the border looks good. How did you find rgba(238, 238, 238, 0)? Why 238? – GG. Feb 01 '12 at 11:06
  • 238,238,238 is a rgb value of #eee which i get from photoshop – sandeep Feb 01 '12 at 11:11
  • Ok but I don't understand all. I put `border-color: rgba(0,0,0,0) #eee rgba(0,0,0,0) rgba(0,0,0,0);` for the content and `border-color: rgba(255,255,255,0) #bbb rgba(255,255,255,0) rgba(255,255,255,0);` for the border, the rendering is good. – GG. Feb 01 '12 at 11:25
1

Solution

I juste removed a few pixels, which corrected the rendering on Firefox.

The rendering is not identical but close enough.

Chrome screenshot

enter image description here

Firefox screenshot

enter image description here

Demo

http://jsfiddle.net/wDff8/1/

Modified code

span.tooltip:after {
  border-width: 10px;
  left: -19px;
  top: -1px;
}
Community
  • 1
  • 1
GG.
  • 21,083
  • 14
  • 84
  • 130