Skip to content

Instantly share code, notes, and snippets.

@Linrstudio
Last active August 29, 2015 14:26
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 Linrstudio/38b24e6e3522685ac4b1 to your computer and use it in GitHub Desktop.
Save Linrstudio/38b24e6e3522685ac4b1 to your computer and use it in GitHub Desktop.
iOS: Fixed position elements on input focus
$(document).ready(function() {
$("input, select, textarea").on('focus', function() {
$("#header").css({
'position': 'absolute',
'top': $(document).scrollTop()
});
focusing = true;
})
$("input, select, textarea").on('blur', function() {
$("#header").css({
'position': 'fixed',
'top': 0
});
focusing = false;
})
});
$(window).scroll(function() {
if ( focusing ) $("#header").css({ 'top': $(document).scrollTop() });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment