Skip to content

Instantly share code, notes, and snippets.

@matthewcopeland
Created August 19, 2012 00:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewcopeland/3390653 to your computer and use it in GitHub Desktop.
Save matthewcopeland/3390653 to your computer and use it in GitHub Desktop.
Display vs Visibility: Avoid bg-image load delays for mobile users.
/*
* image loads on hover.
* users (think mobile) may experience a delay loading the image.
*/
.class {
background-image: url('some-image');
display: none;
}
.class:hover { display: block; }
/*
* image loads on page-load.
* no delay on :hover.
*/
.class {
background-image: url('some-image');
visibility: hidden;
}
.class:hover { visibility: visible; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment