Analysis of NetEase mobile terminal layout example plan

高洛峰
Release: 2017-03-26 10:36:52
Original
1732 people have browsed it

Mobile layout:

rem scheme: Any element on the page adopts rem layout, including fonts. The font-size size of

<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <style type="text/css">
            * {
                margin: 0;
                padding: 0;
            }
            
            body {
                width: 7.5rem;
                font-size: 32px;
                font-size: .32rem;
                max-width: 1080px;
                margin: 0 auto;
                background: #f6f6f6;
                font-family: &#39;STHeiti&#39;, &#39;Microsoft YaHei&#39;, Helvetica, Arial, sans-serif;
                -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            }
        </style>
    </head>

    <body>
        <script type="text/javascript">
            var Dpr = 1,
                uAgent = window.navigator.userAgent;
            var isIOS = uAgent.match(/iphone/i);
            var isYIXIN = uAgent.match(/yixin/i);
            var is2345 = uAgent.match(/Mb2345/i);
            var ishaosou = uAgent.match(/mso_app/i);
            var isSogou = uAgent.match(/sogoumobilebrowser/ig);
            var isLiebao = uAgent.match(/liebaofast/i);
            var isGnbr = uAgent.match(/GNBR/i);

            function resizeRoot() {
                var wWidth = (screen.width > 0) ? (window.innerWidth >= screen.width || window.innerWidth == 0) ? screen.width :
                    window.innerWidth : window.innerWidth,
                    wDpr, wFsize;
                var wHeight = (screen.height > 0) ? (window.innerHeight >= screen.height || window.innerHeight == 0) ?
                    screen.height : window.innerHeight : window.innerHeight;
                if(window.devicePixelRatio) {
                    wDpr = window.devicePixelRatio;
                } else {
                    wDpr = isIOS ? wWidth > 818 ? 3 : wWidth > 480 ? 2 : 1 : 1;
                }
                if(isIOS) {
                    wWidth = screen.width;
                    wHeight = screen.height;
                }
                if(wWidth > wHeight) {
                    wWidth = wHeight;
                }
                wFsize = wWidth > 1080 ? 144 : wWidth / 7.5;
                wFsize = wFsize > 32 ? wFsize : 32;
                window.screenWidth_ = wWidth;
                if(isYIXIN || is2345 || ishaosou || isSogou || isLiebao || isGnbr) { //YIXIN 和 2345 这里有个刚调用系统浏览器时候的bug,需要一点延迟来获取
                    setTimeout(function() {
                        wWidth = (screen.width > 0) ? (window.innerWidth >= screen.width || window.innerWidth == 0) ?
                            screen.width : window.innerWidth : window.innerWidth;
                        wHeight = (screen.height > 0) ? (window.innerHeight >= screen.height || window.innerHeight ==
                            0) ? screen.height : window.innerHeight : window.innerHeight;
                        wFsize = wWidth > 1080 ? 144 : wWidth / 7.5;
                        wFsize = wFsize > 32 ? wFsize : 32;
                        document.getElementsByTagName(&#39;html&#39;)[0].style.fontSize = wFsize + &#39;px&#39;;
                        document.getElementById("fixed").style.display = "none";
                    }, 500);
                } else {
                    document.getElementsByTagName(&#39;html&#39;)[0].style.fontSize = wFsize + &#39;px&#39;;
                    document.getElementById("fixed").style.display = "none";
                }
            }
            resizeRoot();
        </script>
    </body>

</html>
Copy after login

html is automatically calculated based on the mobile device.

The width of the design draft completed by the designer is: 750px. At this time, the size of html and nodes is 50px. Other elements set the rem size according to this benchmark value.

Analysis of NetEase mobile terminal layout example plan

The font-size of the html on the page is not pre-defined in css through the media query, but through js Calculated, for example, the js code part in the above code is to calculate the font-size of html.

The above is the detailed content of Analysis of NetEase mobile terminal layout example plan. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!