The problem with mobile adaptation

Source: Internet
Author: User

The viewport view of the META tag is essential when writing a mobile-side project:

<meta name= "viewport" content= "width=device-width,initial-scale=1.0,maximum-scle=2.0,mininum-scale=1.0, User-scaable=no ">

This code is added so that the width of the page can be equal to the width of the screen, and the initial scale of the display is added to the mobile side, the maximum zoom ratio, the minimum zoom ratio, and whether the user is allowed to scale the screen

Adaptive implementation of the mobile side here, I mainly introduce four ways:

<!--method one REM layout--
<!--Add a font-size= "100px" property to the body and HTML, and the label on the page, whether it's wide, high, or font-size, or some other property, as long as the PX is all changed to REM units,
<script>
function Resetsize () {
var html=document.getelementsbytagname (' html ') [0];
var ww=document.documentelement.clientwidth;
HTML.STYLE.FONTSIZE=WW/PSD width * Start setting fontsize+ "px";
}
Resetsize ();
Window.onresize=function () {
Resetsize ();
}
</script>

<!--method Two zoom layout--
<!--According to the layout of the PSD diagram given and all the dimensions are the same, write directly to the given size.

<script>
function Resetzoom () {
var ww=document.documentelement.clientwidth;
var scale=ww/the width of the current PSD graph;
Document.body.style.zoom=scale;
}
Resetzoom ();
Window.onresize=function () {
Resetzoom ();
}
</script>

<!--method Three percent layout--
<!--both the HTML and the body width and height are 100%, all the margins in the page are set to percentages, but the font size is still using PX;

<!--method Four introduces external files--
<!--before introducing an external file (ort.js), the JQ file must first be introduced, and it is worth noting that all of the content on the page uses the data on the PSD graph--

The problem with mobile adaptation

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.