An Interest In:
Web News this Week
- April 16, 2024
- April 15, 2024
- April 14, 2024
- April 13, 2024
- April 12, 2024
- April 11, 2024
- April 10, 2024
May 8, 2015 08:00 am GMT
Original Link: http://feedproxy.google.com/~r/Noupe/~3/v0kGPn5WA6s/html5-screen-orientation-api-uses-javascript-to-rotate-the-screen-89639.html
HTML5: Screen Orientation API Uses Javascript to Rotate the Screen
Media queries allow websites to adjust their layout depending on the screen orientation of a smartphone or tablet. But sometimes you may want your website locked to a particular orientation, portrait or landscape. The format of native apps can be specified in such a case. The app will then only be displayed in the preset format – independently from the actual device orientation. By using the HTML5 Screen Orientation API, you can now define the screen orientation in JavaScript. Define Screen Orientation for a Document The screen orientation can be adjusted via the screen.orientation property and the lock() method. The method’s default value is “any”. This allows the device to apply any orientation depending on the physical orientation of the device. The value “natural” displays the website in the device’s natural orientation, which varies from device to device. Smartphones usually use the portrait mode, whereas tablets prefer the landscape mode. screen.orientation.lock("natural"); In the above example, it’s set to the natural orientation of the device. Of course, the Screen Orientation API also allows you to define an individual orientation. You can choose between four values, which cover all possible orientations of mobile devices. These are: “portrait-primary”, “portrait-secondary”, “landscape-primary”, and “landscape-secondary”. The […]Original Link: http://feedproxy.google.com/~r/Noupe/~3/v0kGPn5WA6s/html5-screen-orientation-api-uses-javascript-to-rotate-the-screen-89639.html
Share this article:
Tweet
View Full Article
Noupe
Noupe passionately delivers stylish and dynamic news for designers and web-developers across the globe on all subjects of designMore About this Source Visit Noupe