Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS transition flickering in Firefox

I have 3 elements that is growing on :hover using a CSS transition. Two of them work just fine, but the last one is flickering in Firefox, but works in Chrome and IE. So the problem is only there in Firefox.

CSS:

.contact{
    width: 300px;
    height: 250px;
    margin: 10px;
    margin-top: 37px;
    float: right;
    background-color: #eca83b;
    border-radius: 10%;
    transition: 0.5s;
}

.contact:hover{
    width: 320px;
    margin: 0px;
    margin-top: 27px;
    height: 260px;
}

HTML:

<section class="contact">
   <svg> 
   </svg>
   <h2 class="item">Contact</h2>
</section>

What can cause this problem?

like image 635
Morten Saabye Kristensen Avatar asked May 23 '15 11:05

Morten Saabye Kristensen


3 Answers

I had exact same issue: on several sites I've built that use CSS transform scale, there's a flicker the first time you hover over the images. Afterwards they're fine. Doesnt happen on any other browser, and is only recent - obviously a bug in later versions of FF.

Anyway, just fixed it by, of all things, altering the greyscale filter. Try this CSS on your img:

filter: grayscale(1%);

It makes no noticable difference to the colour, but the flicker is gone!

like image 86
Guillaume Roberts Avatar answered Nov 20 '22 22:11

Guillaume Roberts


backface-visibility: hidden tends to fix a lot of flickering issues, try giving it a shot.

like image 31
Luke Avatar answered Nov 20 '22 21:11

Luke


Try putting:

will-change: transform;

Into your .contact

this will pre-render your object into 3d so it should not flicker.

Sometimes it also helps to put it into your class's children, like if you have .contact > .img or something.

like image 6
Aleksey V Avatar answered Nov 20 '22 20:11

Aleksey V