Responsive design is useful when you want the content of your mobile web page to respond to the user's device, such as its screen size and orientation.
With a simple class name, jQuery Mobile is aware of the user's available screen size and automatically resizes itself to show content that is relevant for that particular user.
Responsive tables allow us to display a large set of tabular data that will look attractive for both mobiles and desktops.
There are two types of responsive tables: reflow and column toggle.
The reflow mode positions the table data horizontally until it reaches a minimum size, then all rows are grouped together vertically.
Create a table, add the data-role="table" and a class of "ui-responsive" on the <table> element:
|For the responsive table to work correctly, you must include the <thead> and
Do not use rowspan or colspan attributes; they are not supported in responsive tables.
The "column toggle" mode will hide columns when there is not enough width to display the data.
To create a column toggle table, add the following to the <table> element:
By default, jQuery Mobile will hide columns from the right side of the table. However, you are allowed to specify which column that should be hidden or shown in a specific order. Add the data-priority attribute to the table's header (<th>) and specify a number between 1 (highest priority) to 6 (lowest priority):
|If you do not specify a priority for a column, the column will be persistent and not available for hiding.|
Put it all together and you have created a column toggle table! Notice that the framework automatically adds a button in the top right corner of the table. This lets the user to choose which column to display in the table:
To change the toggle table button text, use the data-column-btn-text attribute:
Use the "ui-shadow" class to add shadows to the table:
For further table styling, use CSS: