- Tutorials / HTML & CSS
- Monday, 1st Nov, 2010
Home » Tutorials » HTML & CSS » CSS3: Media Queries For Multiple Devices
Currently, CSS2 support for the media type, which is the way that allow you to specify style sheet for specific media, such as either screen or print. Now CSS3 added a new function called ‘Media Queries’, which allow you to add expression to check and specify your style sheet more precisely for multiple devices.
There are several features that you can use in media queries, which is
In this article, we will focus on the width, height, device-width, device-height and orientation.
Value: <length>
Applies to: visual and tactile media types
Accepts min/max prefixes: yes
The ‘width’ or ‘height’ media feature is used to describe the width or height of the targeted rendering surface of output device. It’s not the entire screen or page.
The following CSS will apply if the screen viewing area has not exceed 320px:
<link rel="stylesheet" media="screen and (max-width: 320px)" href="mycss.css" />
Value: <length>
Applies to: visual and tactile media types
Accepts min/max prefixes: yes
It used to describe the width or height of the output device, such as the width or height of the entire screen or page (actual resolution of the device), rather than just the rendering area of the device.
The following CSS will apply if the screen viewing area has not exceed 480px:
<link rel="stylesheet" media="screen and (max-device-width: 480px)" href="mycss.css" />
Value: landscape / portrait
Applies to: visual media types
Accepts min/max prefixes: no
It used to indicate the orientation of the device, either in landscape mode or portrait mode.
Example, the following CSS only apply in landscape orientation mode:
<link rel="stylesheet" media="screen and (orientation: landscape)" href="mycss.css" />
The following CSS shows you how to write multiple media queries feature in once:
<link rel="stylesheet" media="screen and (min-device-width: 240px) and (max-device-width: 480px)" href="mycss.css" />
The code above only will apply if the resolution of the device is between 240px and 480px.
Are you enjoying this article? Share it to your friends! and join onlyWebPro Facebook Fan page to get more latest updates!
http://www.facebook.com/pages/Connect-with-onlyWebPro/149917668368025
CSS3: Spinner Animation
Introduction To Device Orientation With HTML5
HTML5 Canvas For Absolute Beginners – Part 4