移动端速查

2020/8/31 移动端

# 移动端速查


# 🐂第一部分:HTML5混生开发

# 1.移动端适配方案(rem)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    * {
        padding: 0;
        margin: 0;
    }
    html,body {
        width: 100%;
        height: 100%;
    }
    .rem-test {
        background: blue;
        width: 100%;
        height: 100%;
    }
</style>
<body>
    
    <div class="rem-test"></div>
    <script>
        !(function(win, doc) {
            var htmlDom = doc.getElementsByTagName('html')[0];
            var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize';
            var recalc = function() {
                var htmlWidth = doc.documentElement.clientWidth || doc.body.clientWidth;
                htmlDom.style.fontSize = htmlWidth / 10 + 'px';
            };

            if (!doc.addEventListener) return;
            win.addEventListener(resizeEvt, recalc, false);
            doc.addEventListener('DOMContentLoaded', recalc, false);
        }(window, document));
    </script>
</body>
</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

# 🐪第二部分:微信小程序


# 🦏第三部分:Flutter


# 🐘第四部分:React-Native


# 🐑第五部分:移动端原生开发


# 📚参考列表(致敬)