Mobile Web Development-handle the screen of a device

Source: Internet
Author: User

In order to cope with the fragmentation of mobile device screens, a best practice when developing an mobile Web application is to use streaming layouts to ensure maximum possible use of limited screen space. Because of the directionality of the screen, when the user switches the direction of the screen, some design or implementation problems are highlighted-at least we need to handle the adaptation of the width of the current display element (which, of course, may be more than just this). Most of the time, we need to design the corresponding application display mode for different screen orientation, this time, it is very important to know the state of the device's vertical screen in real time.

http://dict.baidu.com/s?wd=%E6%B4%9B%E4%B8%BD%E8%AF%97%E4%B8%B0%E8%83%B8+++100%25%E4%B8%B0%E8%83%B8%E6%88%90% e5%8a%9f++%e6%b3%95%e5%9b%bd%e7%94%9f%e7%89%a9%e7%a7%91%e6%8a%80%e5%ae%8c%e7%be%8e%e7%bb%93%e5%90%88

Window.orientation Properties and Onorientationchange events

Window.orientation: This property gives the screen orientation of the current device, 0 for the vertical screen, plus and minus 90 for the horizontal screen (left and right) mode

Onorientationchange: This window event is triggered when the screen orientation is switched between the horizontal and vertical screens, using the same usage as traditional events

Screen orientation

Window.onorientationchange=function () {

if (window.orientation==0) {

Alert ("Vertical screen")

}else{

Alert ("Horizontal screen")

}

};

Mobile Web Development-handle the screen of a device

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.