h5頁面自適應手機屏幕寬度

在html head中添加:javascript

<script type="text/javascript">
  var phoneScale = parseInt(window.screen.width)/640;
  document.write('<meta name="viewport" content="width=640, minimum-scale = '+ phoneScale +', maximum-scale = '+ phoneScale +',   target-densitydpi=device-dpi">');
</script>css

 

在css中給body添加屬性:html

  width: 640px;java

相關文章
相關標籤/搜索