What is the Viewport
手机浏览器是把页面放在一个虚拟的“窗口”(viewport)中,通常这个虚拟的“窗口”(viewport)比屏幕宽
, So do not put each page pushed a small window (this will not undermine the page layout for optimized mobile browser), the user can pan and zoom to different parts of the point of view of the page. Mobile version of the Safari browser, the latest introduction of the viewport meta tag, allows web developers to control the viewport size and scale, other mobile browser also basic support.
Meta Tags
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
width
- the width of the visible region, is a positive integer, or string "device-width"height
- height of the visible region, is a positive integer, or string "device-height"initial-scale
- initial scaling values 1.0 page display actual size, without any scalingminimum-scale
- allows a user to zoom to a minimum ratio, is a number that can be decimalsmaximum-scale
- allows the user to scale the maximum ratio, is a number, can decimalsuser-scalable
- whether the user can manually zoom, is "no" or "yes", no representatives are not allowed, yes to allow representatives
<meta content="telephone=no" name="format-detection" />
<meta content="email=no" name="format-detection" />
telephone
- Digital conversion of whether dial-up link, is "no" or "yes", no representatives are not allowed, yes behalf permitted when set to no,<a href="tel:4006661166"></a>
callemail
- automatic identification of whether the mailbox, is "no" or "yes", no representatives allowed, for the allowed Yes, if set to no, if set to no,<a href="mailto:[email protected]?subject=Hello%20again">
send messages
Gets the value of the scroll bar
window.scrollY window.scrollX
You want to get a desktop browser scroll bar value is through document.scrollTop
and document.scrollLeft
get, android and IOS bywindow.scrollY
window.scrollX
Prohibit copy and paste text
-webkit-user-select:none
Mobile end touch event
touchstart
// trigger When a finger touches the screentouchmove
// When the finger has touched the screen starts to move the triggertouchend
// triggered when the finger leaves the screentouchcancel
// trigger some kind of touch when the event ends abnormally
Trigger order of these four events are:
touchstart -> touchmove -> touchend -> touchcancel
overflow property
overflow attribute specifies when 内容溢出元素框时
things happen
visible
Defaults. Content will not be pruned, there will be elements outside the box.hidden
Content will be trimmed, and the remaining content is not visible.scroll
Content will be trimmed, but the browser will display the scroll bar to view the rest of the content.auto
If the content is pruned, the browser will display the scroll bar to view the rest of the content.inherit
Provision should inherit the value of the overflow property from the parent element.
Load the difference between the image and background-image
During the page load in to the picture background-image css background presence will wait until construction finished loading (content of the page display all later) began to load, and the tag img html is part of the web structure (content) will be in loading the loading process structure, in other words,网页会先加载标签img的内容,再加载背景图片background-image