@viewport
Summary
Specifies the size, zoom factor, and orientation of the viewport.
Examples
@media screen and (max-width:400px) {
@-ms-viewport{
width:320px;
/* the viewport for small devices is set to 320px */
}
@-o-viewport {
width: device-width;
}
@viewport {
width: device-width;
}
}
Notes
Remarks
You can use the @viewport rule in tandem with media queries to help optimize your layout. Typically, you nest the @viewport rule inside the media query, as shown in the following pseudocode snippet: @media [media query logic here] { @viewport { [viewport properties here] } [CSS for this layout combination here] }
Syntax
@viewport { viewport-properties }
Parameters
- viewport-properties
- One or more property declarations, each with a trailing semicolon. Only the following viewport properties are supported.
Value | Meaning |
---|---|
|
Indicates the preferred viewport width used in determining the size of the initial containing block. Can be one of the following values:
|
|
Indicates the preferred viewport height used in determining the size of the initial containing block. See width for a list of possible values. |
Related specifications
- CSS Device Adaptation
- Working Draft
Attributions
Microsoft Developer Network: [Windows Internet Explorer API reference Article]