forked from finance-sh/adaptive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-version3.html
56 lines (56 loc) · 1.72 KB
/
test-version3.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="description" content="javascript H5自适应框架" />
<meta name="Keywords" content="javascript H5自适应框架" />
<title id="title">javascript自适应框架</title>
<link rel="stylesheet" href="css/reset.css">
<script src="js/adaptive.js"></script>
<script>
// 设计图宽度
window['adaptive'].desinWidth = 750;
// body 字体大小
window['adaptive'].baseFont = 24;
/*
// 显示最大宽度
window['adaptive'].maxWidth = 480;
// rem值改变后执行方法
window['adaptive'].setRemCallback = function () {
alert(1)
};
*/
window['adaptive'].scaleType = 3;
// 初始化
window['adaptive'].init();
</script>
<style type="text/css">
.div-1px {
width: 80%;
height: 4rem;
margin: 1rem auto;
border: 1px solid #333;
}
.hairlines .div-1px {
border: .5px solid #0a55bc;
}
</style>
</head>
<body>
<div class="div-1px">在任何手机下,我的边框是标准的1px哦;部分低版本iphone有bug,我们可以用0.5px解决呢</div>
</body>
<script>
(function() {
var isIPhone = !!window.navigator.appVersion.match(/iphone/gi);
if (isIPhone && devicePixelRatio === 2) {
var testElem = document.createElement('div');
testElem.style.border = '.5px solid transparent';
document.body.appendChild(testElem);
if (testElem.offsetHeight == 1)
{
document.querySelector('html').classList.add('hairlines');
}
document.body.removeChild(testElem);
}
})();
</script>
</html>