Question

The setup

I have a series of overlapping CSS hexagons created using pseudo elements with borders. I have hover styles to change the colour of the shapes.

The issue

This hover style is causing problems when the transparent part of the shape overlaps text in other elements, causing a visible corner cut out in the text.

As the problem is difficult to explain with words alone, here is a screenshot highlighting the glitch.

Overlap glitch

The behaviour

I believe this to be a webkit only issue as it appears in Chrome but not Firefox. It may be of note that I am testing this on a Linux Mint system.

The issue occurs when you hover over the small github hexagon and remains when you exit the hex. The issue is resolved only when the large logo hexagon is hovered over. Strangely, if you hover from the logo hex to the github hex the issue only occurs when you exit the github hex.

I have put together a simplified fiddle to demonstrate the issue: http://jsfiddle.net/chicgeek/JRAn5/

The code

I am using SASS, compass, and custom mixins. I've included a snippet of the compiled styles for the offending hex. For a fuller excerpt, see the fiddle above.

.social.github {
    top:1.96875em;
    left:2.0625em;
    display:inline-block;
    text-align:center;
    width:0;
    line-height:0;
}
.social.github:before, .social.github:after {
    position:absolute;
    left:-1em;
    width:1em;
    border:0 solid transparent;
    border-width:0.866em 0.5em;
    content:'';
    z-index:-1
}
.social.github:before {
    border-bottom-color:#c3c3c3;
    border-top:0;
    bottom:0;
}
.social.github:after {
    border-top-color:#c3c3c3;
    border-bottom:0;
    top:0;
}
.social.github:hover:before {
    border-bottom-color:#675e5e;
}
.social.github:hover:after {
    border-top-color:#675e5e;
}

Note: For the fiddle I am importing from Google Fonts, though for my project I have a custom icomoon font. The bug occurs with either source.

The solution..?

Have you encountered this issue before? Do you have a few minutes to play with the fiddle code above? Do you have any suggestions for tactics I could try?

I'm happy to provide more code if it's helpful in diagnosing this problem. Thanks in advance!


Updates

  1. A friend suggested it might be an issue with the font engine. The clipping resolves when the .woff is disabled. [source]
  2. The issue is evident on Chrome 33 (Linux, OSX), Safari (OSX) as well as Chrome 31 (Win7). The issue does not occur on Chrome 33 (Win7).
Was it helpful?

Solution

I asked some work colleagues about my issue. One of them suggested applying -webkit-backface-visibility: hidden; on the logo elements. Voodoo, it worked.

Here is the revised fiddle showing the fix: http://jsfiddle.net/chicgeek/JRAn5/8/

Now the thing is, this shouldn't work as -webkit-backface-visibility is a property specifically for 3D transforms. Though I don't know the specific cause of the issue, I believe my problem to be a webkit-specific bug and it is just chance that this property solves it. If anyone has better understanding of either the reason for the bug or the reason that this solution works, please comment on this answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top