Skip to content

Commit 942ea92

Browse files
committed
Tables: Re-vamped the IE9 CSS hacks to be max-width media queries
This was needed because negating the float and width properties were causing issues, especially on the more complex tables. Using max-width means that we don't need to negate anything. If we can find a clean way to negate these styles, we can simplify things a bit. All demos now work on IE9 and are solid.
1 parent ef8cd40 commit 942ea92

File tree

4 files changed

+50
-37
lines changed

4 files changed

+50
-37
lines changed

css/structure/jquery.mobile.table.reflow.css

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,6 @@
1919
text-align: left;
2020
display: block;
2121
}
22-
/* Make IE9 and WP7.5 treat cells like block level elements */
23-
table.ui-table-reflow,
24-
.ui-table-reflow thead,
25-
.ui-table-reflow tfoot,
26-
.ui-table-reflow tbody,
27-
.ui-table-reflow tr,
28-
.ui-table-reflow th,
29-
.ui-table-reflow td {
30-
width: 100%;
31-
-webkit-box-sizing: border-box;
32-
-moz-box-sizing: border-box;
33-
box-sizing: border-box;
34-
float: left;
35-
clear: left;
36-
}
3722
/* Add a fair amount of top margin to visually separate each row when stacked */
3823
.ui-table-reflow tbody th {
3924
margin-top: 3em;
@@ -60,8 +45,7 @@
6045
}
6146

6247

63-
64-
/* Media query to show as a standard table at 560px (35em x 16px) or wider */
48+
/* Breakpoint to show as a standard table at 560px (35em x 16px) or wider */
6549
@media ( min-width: 35em ) {
6650
/* Show the table header rows */
6751
.ui-table-reflow.ui-responsive td,
@@ -72,23 +56,9 @@
7256
.ui-table-reflow.ui-responsive thead th {
7357
display: table-cell;
7458
margin: 0;
59+
7560
}
76-
/* Undo block styles for IE9 and WP7.5 */
77-
table.ui-table-reflow.ui-responsive,
78-
.ui-table-reflow.ui-responsive thead,
79-
.ui-table-reflow.ui-responsive tfoot,
80-
.ui-table-reflow.ui-responsive tbody,
81-
.ui-table-reflow.ui-responsive tr,
82-
.ui-table-reflow.ui-responsive th,
83-
.ui-table-reflow.ui-responsive td {
84-
width: auto;
85-
float: none;
86-
clear: none;
87-
}
88-
/* Make sure the table is 100% width */
89-
table.ui-table-reflow.ui-responsive {
90-
width: 100%;
91-
}
61+
9262
/* Hide the labels in each cell */
9363
.ui-table-reflow.ui-responsive td .ui-table-cell-label,
9464
.ui-table-reflow.ui-responsive th .ui-table-cell-label {
@@ -97,4 +67,17 @@
9767
}
9868

9969

70+
/* Hack to make IE9 and WP7.5 treat cells like block level elements, scoped to ui-responsive class */
71+
/* Applied in a max-width media query up to the table layout breakpoint so we don't need to negate this*/
72+
@media ( max-width: 35em ) {
73+
.ui-table-reflow.ui-responsive td,
74+
.ui-table-reflow.ui-responsive th {
75+
width: 100%;
76+
-webkit-box-sizing: border-box;
77+
-moz-box-sizing: border-box;
78+
box-sizing: border-box;
79+
float: left;
80+
clear: left;
81+
}
82+
}
10083

docs/demos/tables/financial-grouped-reflow.html

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
<!-- We're using a style block to make it easy to view the custom styles -->
1414
<!-- In production, these should be added to an custom.css file loaded in the head -->
1515
<style>
16+
.th-groups th {
17+
background-color:rgba(0,0,0,0.07);
18+
border-right:1px solid #fff;
19+
text-align:center;
20+
}
1621
@media screen and ( max-width: 72em ) {
17-
1822
/* Style the first cell in a row in a dark bar */
1923
.financial-table-reflow th:first-child
2024
{
@@ -56,6 +60,19 @@
5660
display: none;
5761
}
5862
}
63+
/* Hack to make IE9 and WP7.5 treat cells like block level elements */
64+
/* Applied in a max-width media query up to the table layout breakpoint so we don't need to negate this*/
65+
@media ( max-width: 72em ) {
66+
.financial-table-reflow td,
67+
.financial-table-reflow th {
68+
width: 100%;
69+
-webkit-box-sizing: border-box;
70+
-moz-box-sizing: border-box;
71+
box-sizing: border-box;
72+
float: left;
73+
clear: left;
74+
}
75+
}
5976
</style>
6077
</head>
6178
<body>

docs/demos/tables/movie-list.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,19 @@
100100
display: none;
101101
}
102102
}
103+
/* Hack to make IE9 and WP7.5 treat cells like block level elements */
104+
/* Applied in a max-width media query up to the table layout breakpoint so we don't need to negate this*/
105+
@media ( max-width: 40em ) {
106+
.movie-list td,
107+
.movie-list th {
108+
width: 100%;
109+
-webkit-box-sizing: border-box;
110+
-moz-box-sizing: border-box;
111+
box-sizing: border-box;
112+
float: left;
113+
clear: left;
114+
}
115+
}
103116
</style>
104117
</head>
105118
<body>

docs/tables/table-reflow.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ <h1>Table: Reflow</h1>
2424

2525
<div data-role="content">
2626

27-
<h2>Reflow table mode</h2>
28-
29-
27+
<h2>Reflow table mode</h2>
3028
<p>The reflow table mode works by collapsing the table columns into a stacked presentation that looks like blocks of label/data pairs for each row. Since the HTML source order of a table prohibits styling a table to look like this, the plugin dynamically adds a bit of markup to make the display work (without affecting accessibility). Here is a demo of a basic table using reflow mode:</p>
3129

3230

@@ -166,6 +164,8 @@ <h3>Making the table responsive</h3>
166164
<p>It's best to use a <code>class</code> on the table to apply the breakpoint. Add these rules to your custom stylesheet that is included in the <code>head</code> of the page. We recommend creating a set of custom breakpoint classes that can be used to apply standard table breakpoints in your project.</p>
167165

168166
<p>In the example above, we're assuming there is a class of <code>my-custom-breakpoint</code> added to the table to apply the breakpoint. Each of the rules in the custom media query are scoped against that table class to target only tables that have the <code>my-custom-breakpoint</code> class.</p>
167+
168+
<p>In order for this technique to work, a browser must support media queries and the ability to style table cells as block-level elements. In testing, most popular desktop and mobile browsers meet these criteria, but older versions of Internet Explorer (8 and older) fall back to a normal table presentation. IE 9 can support this technique but there are a few additional styles needed so we recommend applying these in a <code>max-width</code> media query to only apply them below the table presentation because they are hard to negate. </p>
169169

170170
<h3>Choosing a breakpoint</h3>
171171
<p>The goal is to determine the minimum width at which the <em>entire table</em> will fit comfortably within the screen. Find this width by populating a table with realistic sample data, then adjust the browser window until the table completely fits and has a bit of extra space to account for rendering differences across devices. This is the natural place to set the breakpoint that switches between the stacked and tabular presentation modes. </p>

0 commit comments

Comments
 (0)