最近在做一个手机端的项目,WAP端自动适应手机端,代码如下。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" charset="utf-8">
<meta http-equiv="Cache-Control" content="no-transform">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="layoutmode" content="standard">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="renderer" content="webkit">
<meta name="wap-font-scale" content="no">

<script type="text/javascript">
var _htmlFontSize = (function() {
var clientWidth = document.documentElement ? document.documentElement.clientWidth : document.body.clientWidth;
if(clientWidth > 720) clientWidth = 720;
document.documentElement.style.fontSize = clientWidth * 1 / 16 + "px";
return clientWidth * 1 / 16;
})();
</script>

</head>

<body>

内容

</body>
</html>