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
116 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 42

Assisted Solution

by:David S.
David S. earned 150 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 24

Accepted Solution

by:
lenamtl earned 350 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JavaScript Scope issue 4 40
CSS Scroll Issue 3 78
JQuery serialize and unserialize 8 48
How can I echo a PHP variable in AJAX function? 7 27
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Using in-flight Wi-Fi when you travel? Business travelers beware! In-flight Wi-Fi networks could rip the door right off your digital privacy portal. That’s no joke either, as it might also provide a convenient entrance for bad threat actors.
The viewer will learn how to dynamically set the form action using jQuery.
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)

929 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now