Description

The @device context query describes information about the device being use to view the ad.

Example Usage

There are many common uses for having content appear differently depending on the device it is being viewed as different form factors and capabilities can require dramatically different experiences. In the example below, we show a simple use-case of making text bigger when the @device type is smartphone.

.component {
	font-size: 16rem;
}

@device (type: smartphone) {
	.component {
		font-size: 18rem;
	}
	
	/* Other styles to apply when the device is smartphone go here... */
	
}

Available Features

Feature NameJavascript NameValueExample ValueDescription
typedeviceTypedesktop tablet smartphone othersmartphoneThe form-factor of the current device.
os-familydeviceOsFamilystringmac_os_xThe name of the current operating system. All lower-case, spaces should be replaced by an underscore (e.g. mac_os_x).
os-versiondeviceOsVersionnumber10.11.1The current version of the user's browser.
browser-familydeviceBrowserFamilystringchromeThe name of the current browser type. All lower-case, spaces should be replaced by an underscore (e.g. internet_explorer).
browser-versiondeviceBrowserVersionnumber49.0.2623The current version of the user's browser.
screen-widthdeviceScreenWidthnumber480The width in (pixel density neutral) pixels of the device's screen.
screen-heightdeviceScreenHeightnumber640The height in (pixel density neutral) pixels of the device's screen.
screen-aspect-ratiodeviceScreenAspectRationumber0.75The aspect ratio of the device's screen as calculated by width/height.
screen-orientationdeviceScreenOrientationportrait landscapelandscapeDescribes if the shape of the viewport is current in portrait or landscape orientation.
screen-pixel-densitydeviceScreenPixelDensitynumber2The pixel density of the device's screen.
viewport-widthdeviceViewportWidthnumber480`The width of the viewable content area of the screen in pixels.
viewport-heightdeviceViewportHeightnumber640The height of the viewable content area of the screen in pixels.
viewport-aspect-ratiodeviceViewportAspectRationumber0.75The aspect ratio of the viewable content area of the screen as calculated by width/height
viewport-orientationdeviceViewportOrientationportrait landscapeportraitDescribes if the shape of the viewport is current in portrait or landscape orientation.
mobiledeviceMobilebooleantrueA boolean representing if the user's device is mobile device - (a smartphone or tablet).
alphadeviceAlphanumber5The alpha value of the device's orientation in space, as determined by the device's accelerometer.
betadeviceBetanumber0The beta value of the device's orientation in space, as determined by the device's accelerometer.
gammadeviceGammanumber9.2The gamma value of the device's orientation in space, as determined by the device's accelerometer.