2017년 5월 31일 수요일

디바이스에 따라 Viewport Initial Scale과 Width 바꾸기 | Change Viewport Initial Scale and Width Depending on Device Width.

JavaScript

changeViewportMeta = function() {
  var device_width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
  if (device_width < 375) {
    var initial_scale = device_width / 375;
    return $('meta[name=viewport]').attr('content', 'width=device-width, initial-scale='+initial_scale);
  } else {
    return $('meta[name=viewport]').attr('content', 'width=device-width, initial-scale=1');
  }
};
$(window).bind('orientationchange', changeViewportMeta);

$(document).ready(function() {
  changeViewportMeta();
}

Read More

댓글 없음:

댓글 쓰기