Skip to content

Instantly share code, notes, and snippets.

@alamindevms
Created February 8, 2024 04:03
Show Gist options
  • Save alamindevms/5abea897cbf72131fe594c7586bc4978 to your computer and use it in GitHub Desktop.
Save alamindevms/5abea897cbf72131fe594c7586bc4978 to your computer and use it in GitHub Desktop.
Nested Table Design
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nested Table Design</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<section>
<div class="wrapper">
<table class="main-table">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>Address</th>
<th>Country</th>
</tr>
</thead>
<tbody>
<tr>
<td>Al Amin Hossain</td>
<td colspan="3">
<table class="nested-table">
<tr>
<td>[email protected]</td>
<td>01922866947</td>
<td>Dhaka</td>
</tr>
<tr>
<td>[email protected]</td>
<td>01877877866</td>
<td>Motijheel</td>
</tr>
</table>
</td>
<td>Bangladesh</td>
</tr>
<tr>
<td>Jaber Hossain</td>
<td colspan="3">
<table class="nested-table">
<tr>
<td>[email protected]</td>
<td>01877877865</td>
<td>Dhaka</td>
</tr>
<tr>
<td>[email protected]</td>
<td>01877877866</td>
<td>Motijheel</td>
</tr>
</table>
</td>
<td>Bangladesh</td>
</tr>
</tbody>
</table>
</div>
</section>
</body>
</html>
.wrapper {
overflow: auto;
}
.main-table {
width: 100%;
border-collapse: collapse;
}
.main-table thead th {
border: 1px solid red;
padding: 5px 10px;
}
.main-table tbody td {
border: 1px solid red;
padding: 0px;
}
.main-table tbody td:not(:nth-child(2)) {
padding: 5px 10px;
}
.main-table thead tr th:nth-child(2) {
width: 200px;
min-width: 200px;
}
.main-table thead tr th:nth-child(3) {
width: 200px;
min-width: 200px;
}
.nested-table {
width: 100%;
}
.nested-table tr td {
border: 1px solid red;
padding: 5px 15px;
}
.nested-table tr:first-child td {
border-top: 0;
border-left: 0;
border-bottom: 0;
}
.nested-table tr:last-child td {
border-left: 0;
border-bottom: 0;
}
.nested-table tr td:last-child {
border-right: 0;
}
.nested-table tr td:nth-child(1) {
width: 200px;
min-width: 200px;
}
.nested-table tr td:nth-child(2) {
width: 200px;
min-width: 200px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment