Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h3>Nested Tables <small class="text-muted">with tree view-like connecting lines</small></h3>

<br>
<table class="table table-condensed">
	<thead>
		<tr>
			<th></th>
			<th>Header</th>
			<th>Header</th>
			<th>Header</th>
			<th>Header</th>
		</tr>
	</thead>
	<tbody>
		<tr id="tr-detail" class="tr-detail hidden">
			<td></td>
			<td colspan="4">
				<div class="detail-content">
					<ul>
						<li>
							<div class="detail"></div>

							<div class="detail detail-main">
								<fieldset>
									<legend><span class="label label-primary">Nested Data</span></legend>
									<div>
										<table class="table table-condensed">
											<thead>
												<tr>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
												</tr>
											</thead>
											<tr>
												<td>123</td>
												<td>123</td>
												<td>123</td>
												<td>123</td>
												<td>123</td>
											</tr>
											<tr>
												<td>123</td>
												<td>123</td>
												<td>123</td>
												<td>123</td>
												<td>123</td>
											</tr>
										</table>
									</div>
								</fieldset>
								<!-- 								<div class="panel panel-default">
								<div class="panel-heading">Nested Data</div>
									<div class="panel-body">
										<table class="table table-condensed">
											<thead>
												<tr>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
												</tr>
											</thead>
											<tr>
												<td>123</td>
												<td>123</td>
												<td>123</td>
												<td>123</td>
												<td>123</td>
											</tr>
										</table>
									</div>
								</div> -->

							</div>
						</li>
						<li>
							<div class="detail"></div>

							<div class="detail detail-main">
								<fieldset>
									<legend><span class="label label-primary">Nested Data</span></legend>
									<div>
										<table class="table table-condensed">
											<thead>
												<tr>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
												</tr>
											</thead>
											<tr>
												<td>123</td>
												<td>123</td>
												<td>123</td>
												<td>123</td>
												<td>123</td>
											</tr>
										</table>
									</div>
								</fieldset>
								<!-- 								<div class="panel panel-default">
								<div class="panel-heading">Nested Data</div>
									<div class="panel-body">
										<table class="table table-condensed">
											<thead>
												<tr>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
												</tr>
											</thead>
											<tr>
												<td>123</td>
												<td>123</td>
												<td>123</td>
												<td>123</td>
												<td>123</td>
											</tr>
										</table>
									</div>
								</div> -->

							</div>
						</li>
						<li>
							<div class="detail"></div>

							<div class="detail detail-main">
								<fieldset>
									<legend><span class="label label-primary">Nested Data</span></legend>
									<div>
										<table class="table table-condensed">
											<thead>
												<tr>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
												</tr>
											</thead>
											<tr>
												<td>123</td>
												<td>123</td>
												<td>123</td>
												<td>123</td>
												<td>123</td>
											</tr>
										</table>
									</div>
								</fieldset>
								<!-- 								<div class="panel panel-default">
								<div class="panel-heading">Nested Data</div>
									<div class="panel-body">
										<table class="table table-condensed">
											<thead>
												<tr>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
													<th>Header</th>
												</tr>
											</thead>
											<tr>
												<td>123</td>
												<td>123</td>
												<td>123</td>
												<td>123</td>
												<td>123</td>
											</tr>
										</table>
									</div>
								</div> -->

							</div>
						</li>
					</ul>
				</div>
			</td>
		</tr>
		<tr>
			<td><span class="fa fa-chevron-right fa-fw"></span> </td>
			<td>Data</td>
			<td>Data</td>
			<td>Data</td>
			<td>Data</td>
		</tr>
		<tr>
			<td><span class="fa fa-chevron-right fa-fw"></span> </span>
			</td>
			<td>Data</td>
			<td>Data</td>
			<td>Data</td>
			<td>Data</td>
		</tr>
		<tr>
			<td><span class="fa fa-chevron-right fa-fw"></span> </span>
			</td>
			<td>Data</td>
			<td>Data</td>
			<td>Data</td>
			<td>Data</td>
		</tr>
		<tr>
			<td><span class="fa fa-chevron-right fa-fw"></span> </span>
			</td>
			<td>Data</td>
			<td>Data</td>
			<td>Data</td>
			<td>Data</td>
		</tr>
		<tr>
			<td><span class="fa fa-chevron-right fa-fw"></span> </span>
			</td>
			<td>Data</td>
			<td>Data</td>
			<td>Data</td>
			<td>Data</td>
		</tr>
	</tbody>
</table>
<!-- <br>
<div class="row">
	<div class="col-xs-12">
		<table class="table">
			<thead>
				<tr>
					<th></th>
					<th>Header</th>
					<th>Header</th>
					<th>Header</th>
					<th>Header</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td><i class="fa fa-chevron-right fa-fw"></i></td>
					<td>Data</td>
					<td>Data</td>
					<td>Data</td>
					<td>Data</td>
				</tr>
				<tr class="hidden">
					<td colspan="5">
						<div class="collapse">
							<div style="white-space:pre-wrap">
								Lorem ipsum dolor sit amet, consectetur adipiscing elit. In aliquam augue vitae ultrices porttitor. Nulla accumsan lacus eget tempor tristique. Cras nisl metus, maximus sed malesuada ut, ornare eleifend dolor. Nullam fringilla magna at ultrices facilisis.
								Praesent sit amet enim ut ligula porttitor vulputate. Phasellus tortor orci, egestas a magna laoreet, dignissim mollis tellus. Cras mattis augue eu venenatis dignissim. Vivamus ut viverra leo. Quisque sollicitudin elit sed leo euismod, dignissim
								ultricies lectus tincidunt. Sed a vestibulum felis. Aliquam a efficitur nulla. Curabitur et tellus finibus, tempus augue non, ultrices urna.
							</div>
						</div>
					</td>
				</tr>
				<tr class="hidden">
					<tr>
						<td><i class="fa fa-chevron-right fa-fw"></i></td>
						<td>Data</td>
						<td>Data</td>
						<td>Data</td>
						<td>Data</td>
					</tr>
					<td colspan="5">
						<div class="collapse">
							<div style="white-space:pre-wrap">
								Lorem ipsum dolor sit amet, consectetur adipiscing elit. In aliquam augue vitae ultrices porttitor. Nulla accumsan lacus eget tempor tristique. Cras nisl metus, maximus sed malesuada ut, ornare eleifend dolor. Nullam fringilla magna at ultrices facilisis.
								Praesent sit amet enim ut ligula porttitor vulputate. Phasellus tortor orci, egestas a magna laoreet, dignissim mollis tellus. Cras mattis augue eu venenatis dignissim. Vivamus ut viverra leo. Quisque sollicitudin elit sed leo euismod, dignissim
								ultricies lectus tincidunt. Sed a vestibulum felis. Aliquam a efficitur nulla. Curabitur et tellus finibus, tempus augue non, ultrices urna.
							</div>
						</div>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</div> -->
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700");
@import url("https://fonts.googleapis.com/css?family=Roboto:400,300,500,700");
@nt-b-color:#337ab7;@nt-b-style:dashed;


body {
	padding: 20px;
	font-family: "open sans";
	color: #555;
}

label {
	font-weight: 600;
}

table {
	margin-bottom: 0 !important;
	tbody > tr > td:first-child {
		width: 2%;
		white-space: nowrap;
	}
}

span.fa {
	transition: all 400ms;
	&:hover {
		cursor: pointer !important;
		color: #333;
	}
}
.tr-selected{
	>td:not(:first-child){
		background-color:@nt-b-color;
		color:#fff
	}
}
.tr-detail {
	> td {
		padding: 0 !important;
		padding-bottom: 10px !important;
		&:first-child {
			
		}
border-top: none !important;
		&:not(:first-child) {
			// border-top-color:@nt-b-color;
			// border-top-width:2px;
			padding: 5px 5px 5px 5px;
		}
	}
}

.detail-content {
	ul,
	li {
		list-style: none;
		margin: 0;
		padding: 0;
	}
	ul {
		li {
			border: 2px @nt-b-style lighten(@nt-b-color, 0%);
			border-width: 0 0 0px 1px;
			display: flex;
			.detail {
				margin: 0;
				padding:0 10px 5px 0;
				margin-bottom: 10px;
				flex-grow: 1;
				flex-basis: 100%;
				fieldset{
					border: 1px solid lighten(@nt-b-color, 20%);
					legend{
						font-size:90%;
						margin-left:5px;
						width:auto;
						margin-bottom:0;
						border:none;
					}
					>div{
						margin-left:5px;
						margin-right:12px;
						table.table-condensed{
							tbody>tr>td{
								padding:2px;
							}
						}
					}
				}
				// .panel {
				// 	margin: 0;
				// 	border-style: dotted;
				// 	.panel-heading {
				// 		padding: 2px 5px;
				// 		border-bottom-style: dotted;
				// 	}
				// 	.panel-body {
				// 		padding: 5px;
				// 	}
				// }
				&:first-child {
					border-top: 1px @nt-b-style lighten(@nt-b-color, 0%);
					flex-basis: 2%;
					background: #fff;
					margin-top: 15px;
				}
			}
			&:first-child {
				padding-top: 5px;
			}
			&:last-child {
				margin-bottom: 20px;
				> .detail {
					margin-bottom: 0;
					&:first-child {
						margin-left: -1px;
					}
				}
			}
		}
	}
}

              
            
!

JS

              
                (function() {
	$("span.fa").on("click", function() {
		var $span = $(this),
			$parentTr = $span.closest("tr");

		//remove
		if ($span.hasClass("fa-rotate-90")) {
			$span.removeClass("fa-rotate-90");
			$parentTr
				
				.next()
				.children("td")
				.animate({ padding: 0 })
				.wrapInner("<div />")
				.children()
				.slideUp(function() {
					var $tr = $(this).closest("tr");

					// $tr
					// 	.prev("tr")
					// 	.find(".active")
					// 	.removeClass("active");
					$tr.remove();
				$parentTr.removeClass("tr-selected");
				});

			return;
		}

		//add
		$span.addClass("fa-rotate-90");
		if ($parentTr.next().hasClass("tr-detail")) return;
		$parentTr.addClass("tr-selected");
		// 	.eq(1)
		// 	.addClass("active");
		$("#tr-detail")
			.clone()
			.removeClass("hidden")
			.insertAfter($parentTr)
			.children("td")
			.animate()
			.wrapInner("<div style='display:none'/>")
			.children()
			.slideDown();
	});
	
// 	$("i.fa").on("click", function() {
// 		$(this).closest("tr").next().removeClass("hidden").find("div.collapse").collapse("toggle");
// 	});
	
// 	$("div.collapse").on("hidden.bs.collapse", function(){
// 		$(this).closest("tr").children("td").css("padding","0")
// 								$(this).closest("tr").addClass("hidden")
// 								});
})();

              
            
!
999px

Console