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