Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safari 8 label + checkbox hover flicker, how to prevent?

Tags:

html

css

safari

On the first :hover in Safari 8 checkboxes and radio buttons which are checked will flicker as if it is being clicked. Sample code:

<div>
    <label><input type="checkbox" checked> Hover me in Safari 8</label>
</div>

<style>
div {
    background-color: #eee;
    padding: 1em;
}
label {
    line-height: 2em;
    display: block;
}
label:hover {
    background-color: #fff;
}
</style>

I have also created a JSFiddle here, but keep in mind that this only happens on the first hover event and not on subsequent ones. You need to re-run the code to trigger it again.

Does anyone know where this behaviour stems from and how to prevent it? Neither Chrome nor Firefox exhibits this flicker.

Update

I reported this to Apple at bugreporter.apple.com and they closed my issue (radar 21101864) with the status Duplicate of 17781269 (Open).

like image 291
Niklas Brunberg Avatar asked Nov 09 '22 12:11

Niklas Brunberg


1 Answers

Applying -webkit-transform: translateZ(0); to the input element worked for me (dirty though, I know).

like image 109
mgrsskls Avatar answered Nov 15 '22 04:11

mgrsskls