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
149 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 25

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

Ensuring effective and secure communication in the age of healthcare BYOD.
Mobile app development companies have absolutely changed the ways apps are being browsed, used and downloaded by users today.
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…

729 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