Skip to content

Instantly share code, notes, and snippets.

@three-inc
Last active November 3, 2018 03:23
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 three-inc/bf6c026ccbcc147bf8252c7402a90856 to your computer and use it in GitHub Desktop.
Save three-inc/bf6c026ccbcc147bf8252c7402a90856 to your computer and use it in GitHub Desktop.
colorbox.jsの背景を固定する(iOS対応)
$.colorbox({
...
fixed: true,
onOpen: function() {
var ycoord = $(window).scrollTop();
$('#colorbox').data('ycoord',ycoord);
ycoord = ycoord * -1;
$('body').css('position','fixed').css('left','0px').css('right','0px').css('top',ycoord + 'px');
},
onClosed: function() {
$('body').css('position','').css('left','auto').css('right','auto').css('top','auto');
$(window).scrollTop($('#colorbox').data('ycoord'));
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment