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
108 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

You should read OS supplied guidelines before developing. I can't stress that enough. The guidelines will help you understand the reasons mobile app developers do what they do.  Apple is very particular when they review appstore submissions.
By this time the large percentage of day-to-day transactions have shifted to mobile banking; here are some overriding areas QAs must investigate while testing mobile banking apps.  
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)
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

16 Experts available now in Live!

Get 1:1 Help Now