• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

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

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
evibesmusic
Asked:
evibesmusic
2 Solutions
 
David S.Commented:
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
 
lenamtlCommented:
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
 
evibesmusicAuthor Commented:
@All:

Sorry for the late reply.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now