Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to get a 6 column table with no header row to convert into a singular column layout when viewed on mobile?

Posted on 2016-08-04
3
Medium Priority
?
182 Views
Last Modified: 2016-08-09
Experts,

I am using the jQuery Mobile framework.

I have a 6 column table which does not have header row.

I need this table to convert into a singular column when viewed on a mobile device.

I've looked at the jQuery Mobile docs but, all of the examples I find use a header row which my table does not have.

Can this be done via jQuery Mobile or do I need to use some other syntax (HTML5)?

This should be the table layout when viewing on a desktop or larger size device.
<table width="100%">
<tr>
<td>Name:</td>
<td><input type="text" id="name"></td>
<td>Title:</td>
<td><input type="text" id="title"></td>
<td>Position:</td>
<td><input type="text" id="position"></td>
</tr>
</table>

Open in new window


This is what I'd like the table to look like when viewed on a mobile device.
<table width="100%">
<tr>
<td>Name:</td>
</tr>
<tr>
<td><input type="text" id="name"></td>
</tr>
<tr>
<td>Title:</td>
</tr>
<tr>
<td><input type="text" id="title"></td>
</tr>
<tr>
<td>Position:</td>
</tr>
<tr>
<td><input type="text" id="position"></td>
</tr>
</table>

Open in new window

0
Comment
Question by:evibesmusic
3 Comments
 
LVL 43

Assisted Solution

by:David S.
David S. earned 600 total points
ID: 41744263
It seems you haven't read that table elements should only be used to mark up tabular data. That concept predates HTML5 by years.

Anyway, here's a better way to make a responsive form layout:
<!DOCTYPE html>
<html lang="en"><head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<style type="text/css">
label,
input {
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
}
.formGroup .field {
	margin-bottom: .8em;
}
.formGroup label {
	display: block;
}
@media all and (min-width:720px) {
	.formGroup.cols3 {
		width: 100%;
		display: table;
		margin-bottom: .8em; /* margins aren't applied to table-cells */
	}
	.formGroup.cols3 .field {
		width: 33.3%;
		display: table-cell;
	}
	.formGroup.cols3 .field label {
		width: 50%;
		float: left;
		padding-left: 1em;
	}
	.formGroup.cols3 .field input {
		width: 50%;
	}
}
</style>
</head>
<body>

<form action="?">
	<div class="formGroup cols3">
		<div class="field">
			<label for="name">Name:</label>
			<input type="text" id="name">
		</div> <!-- /.field -->
		<div class="field">
			<label for="title">Title:</label>
			<input type="text" id="title">
		</div> <!-- /.field -->
		<div class="field">
			<label for="position">Position:</label>
			<input type="text" id="position">
		</div> <!-- /.field -->
	</div> <!-- /.formGroup -->
</form>

</body>
</html>

Open in new window

0
 
LVL 27

Accepted Solution

by:
lenamtl earned 1400 total points
ID: 41744546
Hi,

 just to let you know that Jquery Mobile Layout is set to five column max, so you will encounter display issue trying  go more then that.
Let say  five-column is using the ui-grid-d class.

You may prefer to use Bootstrap framework which is more flexible for everything not only grid...
Max is 12 columns
http://getbootstrap.com/css/#grid
0
 

Author Closing Comment

by:evibesmusic
ID: 41749271
@All:

Sorry for the late reply.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Owning a franchise can be the dream of a lifetime. It provides a chance for economic growth. You can be as successful as you want.  To make your franchise successful, you need to market it successfully. Here are six of the best marketing strategies …
A new Acronis survey shows people often have conflicting thoughts about data protection.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question