A responsive table

Developer
Size
3,354 Kb
Views
54,648

How do I make an a responsive table?

An example of a responsive table implementing "display: block" on the tr and td elements.. What is a a responsive table? How do you make a a responsive table? This script and codes were developed by Aurer on 03 August 2022, Wednesday.

A responsive table Previews

A responsive table - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>A responsive table</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ body{ padding: 1em; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAQElEQVQIW2P89OvDfwYo+PHjJ4zJwMHBzsAIk0SXAKkCS2KTAEu++vQSbizIKGQAl0SXAJkGlsQmAbcT2Shk+wH0sCzAEOZW1AAAAABJRU5ErkJggg==);
}
a{ color: #739931;
}
.page{ max-width: 60em; margin: 0 auto;
}
table th,
table td{ text-align: left;
}
table.layout{ width: 100%; border-collapse: collapse;
}
table.display{ margin: 1em 0;
}
table.display th,
table.display td{ border: 1px solid #B3BFAA; padding: .5em 1em;
}
table.display th{ background: #D5E0CC; }
table.display td{ background: #fff; }
table.responsive-table{ box-shadow: 0 1px 10px rgba(0, 0, 0, 0.2);
}
@media (max-width: 30em){ table.responsive-table{ box-shadow: none; } table.responsive-table thead{ display: none; } table.display th, table.display td{ padding: .5em; } table.responsive-table td:nth-child(1):before{ content: 'Number'; } table.responsive-table td:nth-child(2):before{ content: 'Name'; } table.responsive-table td:nth-child(1), table.responsive-table td:nth-child(2){ padding-left: 25%; } table.responsive-table td:nth-child(1):before, table.responsive-table td:nth-child(2):before{ position: absolute; left: .5em; font-weight: bold; } table.responsive-table tr, table.responsive-table td{ display: block; } table.responsive-table tr{ position: relative; margin-bottom: 1em; box-shadow: 0 1px 10px rgba(0, 0, 0, 0.2); } table.responsive-table td{ border-top: none; } table.responsive-table td.organisationnumber{ background: #D5E0CC; border-top: 1px solid #B3BFAA; } table.responsive-table td.actions{ position: absolute; top: 0; right: 0; border: none; background: none; }
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div class="page"> <h1>A responsive table</h1>
<table class="layout display responsive-table"> <thead> <tr> <th>Number</th> <th colspan="2">Name</th> </tr> </thead> <tbody> <tr> <td class="organisationnumber">140406</td> <td class="organisationname">Stet clita kasd gubergren, no sea takimata sanctus est</td> <td class="actions"> <a href="?" class="edit-item" title="Edit">Edit</a> <a href="?" class="remove-item" title="Remove">Remove</a> </td> </tr> <tr> <td class="organisationnumber">140412</td> <td class="organisationname">Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat</td> <td class="actions"> <a href="?" class="edit-item" title="Edit">Edit</a> <a href="?" class="remove-item" title="Remove">Remove</a> </td> </tr> <tr> <td class="organisationnumber">140404</td> <td class="organisationname">Vel illum dolore eu feugiat nulla facilisis at vero eros</td> <td class="actions"> <a href="?" class="edit-item" title="Edit">Edit</a> <a href="?" class="remove-item" title="Remove">Remove</a> </td> </tr> <tr> <td class="organisationnumber">140408</td> <td class="organisationname">Iusto odio dignissim qui blandit praesent luptatum zzril delenit</td> <td class="actions"> <a href="?" class="edit-item" title="Edit">Edit</a> <a href="?" class="remove-item" title="Remove">Remove</a> </td> </tr> <tr> <td class="organisationnumber">140410</td> <td class="organisationname"> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam </td> <td class="actions"> <a href="?" class="edit-item" title="Edit">Edit</a> <a href="?" class="remove-item" title="Remove">Remove</a> </td> </tr> </tbody>
</table>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
</body>
</html>

A responsive table - Script Codes CSS Codes

body{ padding: 1em; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAQElEQVQIW2P89OvDfwYo+PHjJ4zJwMHBzsAIk0SXAKkCS2KTAEu++vQSbizIKGQAl0SXAJkGlsQmAbcT2Shk+wH0sCzAEOZW1AAAAABJRU5ErkJggg==);
}
a{ color: #739931;
}
.page{ max-width: 60em; margin: 0 auto;
}
table th,
table td{ text-align: left;
}
table.layout{ width: 100%; border-collapse: collapse;
}
table.display{ margin: 1em 0;
}
table.display th,
table.display td{ border: 1px solid #B3BFAA; padding: .5em 1em;
}
table.display th{ background: #D5E0CC; }
table.display td{ background: #fff; }
table.responsive-table{ box-shadow: 0 1px 10px rgba(0, 0, 0, 0.2);
}
@media (max-width: 30em){ table.responsive-table{ box-shadow: none; } table.responsive-table thead{ display: none; } table.display th, table.display td{ padding: .5em; } table.responsive-table td:nth-child(1):before{ content: 'Number'; } table.responsive-table td:nth-child(2):before{ content: 'Name'; } table.responsive-table td:nth-child(1), table.responsive-table td:nth-child(2){ padding-left: 25%; } table.responsive-table td:nth-child(1):before, table.responsive-table td:nth-child(2):before{ position: absolute; left: .5em; font-weight: bold; } table.responsive-table tr, table.responsive-table td{ display: block; } table.responsive-table tr{ position: relative; margin-bottom: 1em; box-shadow: 0 1px 10px rgba(0, 0, 0, 0.2); } table.responsive-table td{ border-top: none; } table.responsive-table td.organisationnumber{ background: #D5E0CC; border-top: 1px solid #B3BFAA; } table.responsive-table td.actions{ position: absolute; top: 0; right: 0; border: none; background: none; }
}
A responsive table - Script Codes
A responsive table - Script Codes
Home Page Home
Developer Aurer
Username aurer
Uploaded August 03, 2022
Rating 4.5
Size 3,354 Kb
Views 54,648
Do you need developer help for A responsive table?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Aurer (aurer) Script Codes
Create amazing love letters with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!