Skip to content

Instantly share code, notes, and snippets.

@NOEinteractive
Created October 9, 2013 15:40
Show Gist options
  • Save NOEinteractive/6903261 to your computer and use it in GitHub Desktop.
Save NOEinteractive/6903261 to your computer and use it in GitHub Desktop.
Hover accessible et touch friendly
<div id="wrapper">
<div class="foo">
<span class="bar"></span>
</div>
<div class="foo">
<span class="bar"></span>
</div>
<div class="foo">
<span class="bar"></span>
</div>
<div class="foo">
<span class="bar"></span>
</div>
</div>
if(Modernizr.touch) {
$('#wrapper').on('click', 'div.foo', function(e) {
$(e.currentTarget).toggleClass('hover');
});
}
.no-js .foo:hover .bar,
.no-touch .foo:hover .bar,
.touch .foo.hover .bar {
/*les styles du hover*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment