2

I have taken a tooltip from another Stack Overflow post, and slightly modified it. It looks like this:

Tooltip image

Generated from the following code:

.up-arrow {
    display: inline-block;
    position: relative;
    border: 1px solid black;
    text-decoration: none;
    border-radius: 2px;
    padding: 20px;
    margin-top: 50px;
}
.up-arrow:before {
    content: '';
    display: block;  
    position: absolute;
    left: 140px;
    bottom: 100%;
    width: 0;
    height: 0;
    border: 10px solid transparent;
    border-bottom-color: black;
} 

.up-arrow:after {
    content: '';
    display: block;  
    position: absolute;
    left: 141px;
    bottom: 100%;
    width: 0;
    height: 0;
    border: 9px solid transparent;
    border-bottom-color: white;
}
<div href="#" class="up-arrow">Button with Up Arrow</div>

If you look very closely, you can see that the color of the :before element is not actually black, it is #77777.

Eyedropper check

This problem has left my coworkers and I stumped. It is consistent across browsers. Can anyone provide some insight?

3rdthemagical
  • 5,271
  • 18
  • 36

1 Answers1

2

.up-arrow {
    display: inline-block;
    position: relative;
    border: 1px solid black;
    text-decoration: none;
    border-radius: 2px;
    padding: 20px;
    margin-top: 50px;
}
.up-arrow:before {
    content: '';
    display: block;  
    position: absolute;
    left: 140px;
    bottom: 100%;
    width: 0;
    height: 0;
    border: 10px solid transparent;
    border-bottom-color: black;
} 

.up-arrow:after {
    content: '';
    display: block;  
    position: absolute;
    left: 141px;
    top: -17px;
    bottom: 100%;
    width: 0;
    height: 0;
    border: 9px solid transparent;
    border-bottom-color: white;
}
<div href="#" class="up-arrow">Button with Up Arrow</div>

Your problem is antialiasing, which is trying to make your line look smooth. You can make it true black by moving the :after element 1 pixel or so further away from the diagonals, so that the line is thicker and antialiasing only affects the outside pixels not the inner pixels, but whether this is desirable is another question. It looks slightly odd.

Said effect is achieved in the snippet above by adding top: -17px to the :after element.

3rdthemagical
  • 5,271
  • 18
  • 36
ArtOfCode
  • 5,702
  • 5
  • 37
  • 56