Responsive Layout Helpers

Media Query Helper Classes

jQuery Mobile adds classes to the HTML element that mimic browser orientation and common min/max-width CSS media queries. These classes are updated on load, resize and orientationchange, allowing you to key off these classes in your CSS, to create responsive layouts - even in browsers that don't support media queries!

Orientation Classes

The HTML element will always have a class of either "portrait" or "landscape", depending on the orientation of the browser or device. You can utilize these in your CSS like this:

.portrait {
	/* portrait orientation changes go here! */
.landscape {
	/* landscape orientation changes go here! */

Min/Max Width Breakpoint Classes

By default, we create min and max breakpoint classes at the following widths: 320,480,768,1024. These translate to classes that look like this: "min-width-320px", "max-width-480px", and are meant to be used as a replacement of (or in addition to) the media query equivalents they mimic.

.myelement { 
	float: none;
.min-width-480px .myelement {
	float: left;

Many plugins in jQuery Mobile leverage these width breakpoints. For example, form elements float beside their labels when the browser is wider than 480 pixels. The CSS to support this behavior for form text inputs looks like this:

label.ui-input-text { 
	display: block; 
.min-width-480px label.ui-input-text { 
	display: inline-block; 

Adding Width Breakpoints

To utilize width breakpoints of your own, jQuery Mobile exposes the $.mobile.addResolutionBreakpoints function, which accepts either a single number or array of numbers that will be added to the min/max breakpoints whenever they apply.

//add a min/max class for 1200 pixel widths			

//add min/max classes for 1200, and 1440 pixel widths			
$.mobile.addResolutionBreakpoints([1200, 1440]);