Mobile-side adaptation

Source: Internet
Author: User

Impact Factor: 1 device Physical pixel 2 scaling 3 DPR

Set the ideal viewport

<meta name= "viewport" content= "width=device-width,initial-scale=1.0" >

Method 1 Fixed height, Width adaptive: Vertical direction with fixed value, horizontal direction percentage, fixed value, Flex line.

Principle:<meta name="viewport" content="width=device-width,initial-scale=1">

Method 2 fixed width, viewport scaling: Viewport width uses a width, the browser automatically completes the zoom, the unit uses PX.

Principle: the need to dynamically generate viewport based on screen width, generated similar<meta name="viewport" content="width=640,initial-scale=0.5,maximum-scale=0.5,minimum-scale=0.5,user-scalable=no">

Method 3 Rem Do width, viewport zoom

Depending on the screen width, the REM value is set, and the element that needs to be adapted uses REM and does not need to be a matching element using PX.

Principle: 1 Dynamically generated viewport, set to 1/DPR 2 screen width set REM size, that is, to HTML settings Font-size 3 based on device pixel than window.devicepixelratio to set DATA-DPT

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.