Row head sticky not working when change some column sticky - html

In previous table's row head sticky was working well. Then I did some changes to the first and second columns fixed. Then after row head sticky is not working. I can not find where I was wrong. I added my code below.
CSS -->
.view {
margin: auto;
width: 100%;
}
.wrapper {
position: relative;
overflow: auto;
white-space: nowrap;
}
.sticky-col {
position: sticky;
position: -webkit-sticky;
background-color: white;
z-index:1;
}
.first-col {
width: 100px;
min-width: 100px;
max-width: 100%;
left: 0px;
}
.second-col {
width: 150px;
min-width: 150px;
max-width: 100%;
left: 100px;
}
th {
background: white;
position: sticky;
top: 0;
}
Table -->
<div class="view">
<div class="wrapper">
<table>
<thead>
<tr>
<th class="sticky-col first-col">Col 1</th>
<th class="sticky-col second-col">Col 2</th>
<th>...</th>
<th>...</th>
</tr>
</thead>
<tbody>
<tr>
<td class="sticky-col first-col"></td>
<td class="sticky-col second-col"></td>
<td>...</td>
<td>...</td>
</tr>
</tbody>
</table>
</div>
I have added below CSS to do row head stick in main.handlerbars.
th {
background: white;
position: sticky;
top: 0;
}
If you can give me a fix to solve this will be a huge help. Thank you.

You need to increase the z-index of the sticky left elements. Since you made all the element to be sticky, the latter ones will overlap the previous ones:
.view {
margin: auto;
width: 100%;
}
.wrapper {
position: relative;
overflow: auto;
white-space: nowrap;
height:100px;
}
.sticky-col {
position: sticky;
position: -webkit-sticky;
background-color: white;
}
.first-col {
width: 100px;
min-width: 100px;
max-width: 100%;
left: 0px;
}
.second-col {
width: 150px;
min-width: 150px;
max-width: 100%;
left: 100px;
}
th {
background: white;
position: sticky;
top: 0;
}
th.sticky-col {
z-index:1;
}
<div class="view">
<div class="wrapper">
<table id="app" class='table table-bordered table-sm'>
<thead>
<tr>
<th class="sticky-col first-col">Product</th>
<th class="sticky-col second-col">Description</th>
<th>Lorem ipsum dolor sit amet, consectetur</th>
<th>Lorem ipsum dolor sit amet, consectetur</th>
</tr>
</thead>
<tbody>
<tr>
<td class="sticky-col first-col">consectetur </td>
<td class="sticky-col second-col">consectetur </td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam fringilla metus lorem, a malesuada sem tempor ac. Sed auctor, diam sed sodales vulputate, quam enim pulvinar ante, sed sollicitudin arcu est sit amet justo. Donec ac leo blandit, facilisis purus non, fringilla velit. Sed vel tempor eros, vel </td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam fringilla metus lorem, a malesuada sem tempor ac. Sed auctor, diam sed sodales vulputate, quam enim pulvinar ante, sed sollicitudin arcu est sit amet justo. Donec ac leo blandit, facilisis purus non, fringilla velit. Sed vel tempor eros, vel </td>
</tr>
<tr>
<td class="sticky-col first-col">consectetur </td>
<td class="sticky-col second-col">consectetur </td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam fringilla metus lorem, a malesuada sem tempor ac. Sed auctor, diam sed sodales vulputate, quam enim pulvinar ante, sed sollicitudin arcu est sit amet justo. Donec ac leo blandit, facilisis purus non, fringilla velit. Sed vel tempor eros, vel </td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam fringilla metus lorem, a malesuada sem tempor ac. Sed auctor, diam sed sodales vulputate, quam enim pulvinar ante, sed sollicitudin arcu est sit amet justo. Donec ac leo blandit, facilisis purus non, fringilla velit. Sed vel tempor eros, vel </td>
</tr>
<tr>
<td class="sticky-col first-col">consectetur </td>
<td class="sticky-col second-col">consectetur </td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam fringilla metus lorem, a malesuada sem tempor ac. Sed auctor, diam sed sodales vulputate, quam enim pulvinar ante, sed sollicitudin arcu est sit amet justo. Donec ac leo blandit, facilisis purus non, fringilla velit. Sed vel tempor eros, vel </td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam fringilla metus lorem, a malesuada sem tempor ac. Sed auctor, diam sed sodales vulputate, quam enim pulvinar ante, sed sollicitudin arcu est sit amet justo. Donec ac leo blandit, facilisis purus non, fringilla velit. Sed vel tempor eros, vel </td>
</tr>
<tr>
<td class="sticky-col first-col">consectetur </td>
<td class="sticky-col second-col">consectetur </td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam fringilla metus lorem, a malesuada sem tempor ac. Sed auctor, diam sed sodales vulputate, quam enim pulvinar ante, sed sollicitudin arcu est sit amet justo. Donec ac leo blandit, facilisis purus non, fringilla velit. Sed vel tempor eros, vel </td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam fringilla metus lorem, a malesuada sem tempor ac. Sed auctor, diam sed sodales vulputate, quam enim pulvinar ante, sed sollicitudin arcu est sit amet justo. Donec ac leo blandit, facilisis purus non, fringilla velit. Sed vel tempor eros, vel </td>
</tr>
</tbody>
</table>
</div>

Related

Sticky navbar disappears on scroll

How can I make the sticky navbar stick to top of the page even after I provide a static height on sections below? Now when I scroll to the point of test-section then the nav disappears. How can I avoid this?
.header {
position: sticky;
top: 0;
z-index: 100;
height: 50px;
background: blue;
}
.test-section {
height: 300px;
background: red;
}
<div>
<div class="header">
hi navbar
</div>
<div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis et dolor tellus. Fusce laoreet nibh at nisl iaculis sollicitudin. Nullam dapibus, est vitae aliquet consectetur, velit ipsum vestibulum ante, et hendrerit enim erat non odio. Nullam sit amet nisi dictum, suscipit diam nec, pellentesque urna. Quisque semper turpis vitae suscipit eleifend. Mauris sed nisl at eros tristique accumsan vitae nec libero. Cras et laoreet mauris, eget posuere ipsum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis et dolor tellus. Fusce laoreet nibh at nisl iaculis sollicitudin. Nullam dapibus, est vitae aliquet consectetur, velit ipsum vestibulum ante, et hendrerit enim erat non odio. Nullam sit amet nisi dictum, suscipit diam nec, pellentesque utur, ve
</p>
</div>
<div class="test-section">
<img src="https://commonslibrary.parliament.uk/content/uploads/2018/02/The_City_London-scaled.jpg">
</div>
Use "position: fixed" instead on the class header
Changing from position: sticky; to position: fixed; and also adding width: 100%; to your .header class seems to get the result your looking for
.header {
position: fixed;
top: 0;
z-index: 100;
height: 50px;
width:100%;
background: blue;
}
.test-section {
height: 300px;
background: red;
}
<div>
<div class="header">
hi navbar
</div>
<div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis et dolor tellus. Fusce laoreet nibh at nisl iaculis sollicitudin. Nullam dapibus, est vitae aliquet consectetur, velit ipsum vestibulum ante, et hendrerit enim erat non odio. Nullam sit amet nisi dictum, suscipit diam nec, pellentesque urna. Quisque semper turpis vitae suscipit eleifend. Mauris sed nisl at eros tristique accumsan vitae nec libero. Cras et laoreet mauris, eget posuere ipsum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis et dolor tellus. Fusce laoreet nibh at nisl iaculis sollicitudin. Nullam dapibus, est vitae aliquet consectetur, velit ipsum vestibulum ante, et hendrerit enim erat non odio. Nullam sit amet nisi dictum, suscipit diam nec, pellentesque utur, ve
</p>
</div>
<div class="test-section">
<img src="https://commonslibrary.parliament.uk/content/uploads/2018/02/The_City_London-scaled.jpg">
</div>
.header {
position: fixed;
top: 0;
z-index: 100;
height: 50px;
background: blue;
}

Wrapping longer table under adjacent, shorter table

Per the following screenshot, I have two <div> elements, each containing tables, with those <div> placed adjacent to one another. Additionally, the <body> content is placed below those <div>.
How can I wrap the left table under the right one, if the there is unused space under the right table?
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Adjacent table wrapping</title>
<style>
table {
border: 1px solid black;
border-collapse: collapse;
}
table td {
border: 1px solid black;
padding: 0.0rem 0.25rem 0.0rem 0.5rem;
}
table tr:nth-child(odd) { background-color: #edf0f0; }
#left_div {
float: left;
wrap:inline;
width: 60%;
}
#left_div table td:first-child {
}
#right_div {
float: right;
clear: right;
width: 39%;
}
/* Without the following, "clear: left;", if there was space between the
* "left_div" and the "right_div", then the body text was wrapping between
* those adjacent (float {left | right}) <div>. The solution, per
* https://stackoverflow.com/questions/3258944/how-can-stop-text-wrapping-around-some-floated-divs
* was to add
* <div id="clear_left"></div>
* which enables text to both flow below the "left_div", and also to the left
* of the "right_div".
*/
#clear_left {
clear: left;
}
</style>
</head>
<body>
<!-- LEFT DIV -->
<div id="left_div">
<table>
<tr>
<td>URL</td>
<td>example.com</td>
</tr>
<tr>
<td>Source</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</td>
</tr>
<tr>
<td>Year</td>
<td>2021</td>
</tr>
<tr>
<td>Modified</td>
<td>July 01, 2021</td>
</tr>
<tr>
<td>Comment</td>
<td> Suspendisse efficitur pulvinar elementum.</td>
</tr>
<tr>
<td>Key points</td>
<td>
<ul>
<li class="body">Vestibulum a est eu erat rutrum scelerisque non et diam.</li>
<li class="body">Nam ut fringilla enim.</li>
</ul>
</td>
</tr>
<tr>
<td>Notes</td>
<td>Pellentesque finibus mauris vel nulla euismod mollis. Nunc sit amet euismod purus, ut viverra neque.</td>
</tr>
<tr>
<td>More notes</td>
<td>Quisque eget ante efficitur, dignissim felis nec, tempor dolor. Curabitur elementum dui et odio pharetra varius. Phasellus molestie ullamcorper nulla. Morbi finibus nisi a consequat mollis. Etiam in sagittis sapien, sit amet commodo augue.</td>
</tr>
<tr>
<meta name="summary" content="" />
<td>Summary</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse efficitur pulvinar elementum. Vestibulum a est eu erat rutrum scelerisque non et diam. Nam ut fringilla enim. Pellentesque finibus mauris vel nulla euismod mollis. Nunc sit amet euismod purus, ut viverra neque. Quisque eget ante efficitur, dignissim felis nec, tempor dolor. Curabitur elementum dui et odio pharetra varius. Phasellus molestie ullamcorper nulla. Morbi finibus nisi a consequat mollis. Etiam in sagittis sapien, sit amet commodo augue.</td>
</tr>
</table>
</div>
<!-- RIGHT DIV -->
<div id="right_div">
<table>
<tr>
<td colspan="2">
<b><center>Flag of Canada</center></b>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Flag_of_Canada_%28Pantone%29.svg/1280px-Flag_of_Canada_%28Pantone%29.svg.png" alt="Flag of Canada" width="400"/>
</td>
</tr>
</table>
</div>
<!-- Prevent <body> content between "left_div" and "right_div": -->
<div id="clear_left"></div>
<!-- ---------------------------------------------------------------------- -->
<h2>Content</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse efficitur pulvinar elementum. Vestibulum a est eu erat rutrum scelerisque non et diam. Nam ut fringilla enim. Pellentesque finibus mauris vel nulla euismod mollis. Nunc sit amet euismod purus, ut viverra neque. Quisque eget ante efficitur, dignissim felis nec, tempor dolor. Curabitur elementum dui et odio pharetra varius. Phasellus molestie ullamcorper nulla. Morbi finibus nisi a consequat mollis. Etiam in sagittis sapien, sit amet commodo augue.</p>
</body>
Truly dynamically sized L-shaped tables are (at this time) impossible to achieve.
Grid might support it in the future.
Until then, you have to compromise on some level.
If you can reasonably estimate the size of the image and the size of first couple or rows then rowspan might be a good solution, having the image span the length of the first couple of rows.
Or if your content allows for it, you could mimic a table like behavior in css, and have the image float:right alongside it.
.table {
border-bottom: 1px solid black;
}
.table div.row {
padding: 0.0rem 0.25rem 0.0rem 0.5rem;
border-right: 1px solid black;
border-left: 1px solid black;
border-top: 1px solid black;
display: flex;
}
.table div.row span {}
.table div.row span:first-child {
border-right: 1px solid black;
display: inline-block;
min-height: 100%;
min-width: 70px;
display: flex;
justify-content: center;
align-items: center;
padding-right: 0.5rem;
}
.table div.row span:last-child {
padding-left: 0.5rem;
}
.table div.row:nth-child(odd) {
background-color: #edf0f0;
}
.right_div {
float: right;
clear: right;
padding: 10px;
padding-top: 0;
background-color: white;
}
.flag {
padding: 10px;
background-color: #edf0f0;
border: 1px solid black;
}
<!-- LEFT DIV -->
<div id="left_div">
<div class="table">
<div class="right_div">
<div class="flag">
<b><center>Flag of Canada</center></b>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Flag_of_Canada_%28Pantone%29.svg/1280px-Flag_of_Canada_%28Pantone%29.svg.png" alt="Flag of Canada" width="340" />
</div>
</div>
<div class="row">
<span>URL</span>
<span>example.com</span>
</div>
<div class="row">
<span>Source</span>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
</div>
<div class="row">
<span>Year</span>
<span>2021</span>
</div>
<div class="row">
<span>Modified</span>
<span>July 01, 2021</span>
</div>
<div class="row">
<span>Comment</span>
<span> Suspendisse efficitur pulvinar elementum.</span>
</div>
<div class="row">
<span>Key points</span>
<span>
<ul>
<li class="body">Vestibulum a est eu erat rudivum scelerisque non et diam.</li>
<li class="body">Nam ut fringilla enim.</li>
</ul>
</span>
</div>
<div class="row">
<span>Notes</span>
<span>Pellentesque finibus mauris vel nulla euismod mollis. Nunc sit amet euismod purus, ut viverra neque.</span>
</div>
<div class="row">
<span>More notes</span>
<span>Quisque eget ante efficitur, dignissim felis nec, tempor dolor. Curabitur elementum dui et odio pharediva varius. Phasellus molestie ullamcorper nulla. Morbi finibus nisi a consequat mollis. Etiam in sagittis sapien, sit amet commodo augue.</span>
</div>
<div class="row">
<span>Summary</span>
<meta name="summary" content="" />
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse efficitur pulvinar elementum. Vestibulum a est eu erat rudivum scelerisque non et diam. Nam ut fringilla enim. Pellentesque finibus mauris vel nulla euismod mollis. Nunc sit amet euismod purus, ut viverra neque. Quisque eget ante efficitur, dignissim felis nec, tempor dolor. Curabitur elementum dui et odio pharediva varius. Phasellus molestie ullamcorper nulla. Morbi finibus nisi a consequat mollis. Etiam in sagittis sapien, sit amet commodo augue.</span>
</div>
</div>
</div>

How to vertically align text in Bootstrap table

I am attempting to vertically align my text in the center of its row regardless of how long the text is in my bootstrap table.
I am attempting to handle this with vertical-align: middle; line-height:90px; At the moment adjusting the line-height seems to work and allow me get text in the center but if the text is two-lines then the line-gap between the two is too large.
How can I vertically align my text in the right column to fit vertically be in the middle of the page?
Here is my code snippet :
.table-bordered th, tbody td:nth-child(2) {
vertical-align: middle;
line-height: 90px;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<table class="table table-bordered">
<thead class="text-14 tx-light">
<tr class="d-flex">
<th class="col-6 blue-background" scope="col">LEFT</th>
<th class="col-6 red-background" scope="col">RIGHT</th>
</tr>
</thead>
<tbody class="text-18 tx-dark">
<tr class="d-flex">
<td class="col-6" scope="row">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus bibendum placerat sapien, vel consectetur dolor congue id. Duis posuere nisl eget magna posuere malesuada. Nunc ac euismod nulla. Nunc efficitur tincidunt facilisis. Proin sed efficitur velit. Donec non sem sed lorem faucibus finibus. Cras tristique turpis vitae scelerisque fringilla.
</td>
<td class="col-6"> <a class="text-underlined-18 ul-link">Link to the described article here </a></td>
</tr>
<tr class="d-flex">
<td class="col-6" scope="row">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus bibendum placerat sapien, vel consectetur dolor congue id. Duis posuere nisl eget magna posuere malesuada. Nunc ac euismod nulla. Nunc efficitur tincidunt facilisis. Proin sed efficitur velit. Donec non sem sed lorem faucibus finibus. Cras tristique turpis vitae scelerisque fringilla.
</td>
<td class="col-6"> <a class="text-underlined-18 ul-link">Link to longer url that takes up two lines here test test test test </a></td>
</tr>
<tr class="d-flex">
<td class="col-6" scope="row">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus bibendum placerat sapien, vel consectetur dolor congue id. Duis posuere nisl eget magna posuere malesuada. Nunc ac euismod nulla. Nunc efficitur tincidunt facilisis. Proin sed efficitur velit. Donec non sem sed lorem faucibus finibus. Cras tristique turpis vitae scelerisque fringilla.
</td>ib
<td class="col-6"> <a class="text-underlined-18 ul-link"> Link to article here</a></td>
</tr>
</tbody>
</table>
I am expecting my text to sit in the center of the row similar to this photo without the huge line gap if the text is two-lines:
Change the desired table data element to display: flex;, make the flex-direction: column; and justify-content: center;.
.table-bordered th, tbody td:nth-child(2) {
display: flex;
flex-direction: column;
justify-content: center;
line-height: 90px;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<table class="table table-bordered">
<thead class="text-14 tx-light">
<tr class="d-flex">
<th class="col-6 blue-background" scope="col">LEFT</th>
<th class="col-6 red-background" scope="col">RIGHT</th>
</tr>
</thead>
<tbody class="text-18 tx-dark">
<tr class="d-flex">
<td class="col-6" scope="row">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus bibendum placerat sapien, vel consectetur dolor congue id. Duis posuere nisl eget magna posuere malesuada. Nunc ac euismod nulla. Nunc efficitur tincidunt facilisis. Proin sed efficitur velit. Donec non sem sed lorem faucibus finibus. Cras tristique turpis vitae scelerisque fringilla.
</td>
<td class="col-6"> <a class="text-underlined-18 ul-ibisworld">Link to the described article here </a></td>
</tr>
<tr class="d-flex">
<td class="col-6" scope="row">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus bibendum placerat sapien, vel consectetur dolor congue id. Duis posuere nisl eget magna posuere malesuada. Nunc ac euismod nulla. Nunc efficitur tincidunt facilisis. Proin sed efficitur velit. Donec non sem sed lorem faucibus finibus. Cras tristique turpis vitae scelerisque fringilla.
</td>
<td class="col-6"> <a class="text-underlined-18 ul-ibisworld">Link to longer url that takes up two lines here test test test test </a></td>
</tr>
<tr class="d-flex">
<td class="col-6" scope="row">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus bibendum placerat sapien, vel consectetur dolor congue id. Duis posuere nisl eget magna posuere malesuada. Nunc ac euismod nulla. Nunc efficitur tincidunt facilisis. Proin sed efficitur velit. Donec non sem sed lorem faucibus finibus. Cras tristique turpis vitae scelerisque fringilla.
</td>
<td class="col-6"> <a class="text-underlined-18 ul-ibisworld"> Link to article here</a></td>
</tr>
</tbody>
</table>

Sliding animation for sub rows in a table

I want to add a sliding animation for sub rows inside a table structure. When using the div tag inside a table, it does not works like a div outside of the table structure. The animation is missing and it is formatting every sub td in the first td of the parent row.
Source code - here the StackBlitz example
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr (click)="show = !show">
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<ng-container *ngIf="show">
<div class="box" [class.opened]="show">
<tr>
<td>Sam</td>
<td>Sample</td>
<td>35</td>
</tr>
<tr>
<tr>
<td>Piet</td>
<td>Miller</td>
<td>42</td>
</tr>
</div>
</ng-container>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
<div style="margin-top: 20px" class="box" [class.opened]="show">
Here the animation is working proper. <br> <br>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Neque ornare aenean euismod elementum nisi quis eleifend. Vivamus at augue eget arcu dictum. Dui sapien eget mi proin sed libero enim sed faucibus. Justo laoreet sit amet cursus sit amet dictum sit. Varius sit amet mattis vulputate. Lorem ipsum dolor sit amet consectetur adipiscing elit. Convallis tellus id interdum velit laoreet id donec ultrices. Tempus urna et pharetra pharetra massa massa. Tempor commodo ullamcorper a lacus vestibulum sed arcu non odio. Sagittis eu volutpat odio facilisis mauris sit amet massa vitae. Semper auctor neque vitae tempus quam pellentesque nec nam. Mauris nunc congue nisi vitae suscipit tellus mauris. Eget magna fermentum iaculis eu. Mi in nulla posuere sollicitudin. Nibh mauris cursus mattis molestie a iaculis at erat pellentesque. Nam libero justo laoreet sit amet. Aliquam faucibus purus in massa. Velit ut tortor pretium viverra suspendisse potenti nullam ac.
</div>
CSS
.box {
background-color: #FFCC55;
max-height: 0px;
overflow-y: hidden;
transition: ease-in-out 400ms max-height;
}
.box.opened {
max-height: 500px;
transition: ease-in-out 600ms max-height;
}
You only have to remove 'ng-container'. It will solve your problem.
Replace this code
<ng-container *ngIf="show">
<div class="box" [class.opened]="show">
<tr>
<td><div>Sam</div></td>
<td><div>Sample</div></td>
<td><div>35</div></td>
</tr>
<tr></tr>
<tr>
<td><div>Piet</div></td>
<td><div>Miller</div></td>
<td><div>42</div></td>
</tr>
</div>
</ng-container>
With this one
<div class="box" [class.opened]="show">
<tr>
<td><div>Sam</div></td>
<td><div>Sample</div></td>
<td><div>35</div></td>
</tr>
<tr></tr>
<tr>
<td><div>Piet</div></td>
<td><div>Miller</div></td>
<td><div>42</div></td>
</tr>
</div>
If you want 'ng-container' should be in your code then put it inside of div (which has the class box). But it slows your animation.
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr (click)="show = !show">
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<ng-container *ngIf="show">
<tr class="box" [class.opened]="show">
<td><div>Sam</div></td>
<td><div>Sample</div></td>
<td><div>35</div></td>
</tr>
<tr>
<td><div>Piet</div></td>
<td><div>Miller</div></td>
<td><div>42</div></td>
</tr>
</ng-container>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
<div style="margin-top: 20px" class="box" [class.opened]="show">
Here the animation is working proper. <br> <br>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Neque ornare aenean euismod elementum nisi quis eleifend. Vivamus at augue eget arcu dictum. Dui sapien eget mi proin sed libero enim sed faucibus. Justo laoreet sit amet cursus sit amet dictum sit. Varius sit amet mattis vulputate. Lorem ipsum dolor sit amet consectetur adipiscing elit. Convallis tellus id interdum velit laoreet id donec ultrices. Tempus urna et pharetra pharetra massa massa. Tempor commodo ullamcorper a lacus vestibulum sed arcu non odio. Sagittis eu volutpat odio facilisis mauris sit amet massa vitae. Semper auctor neque vitae tempus quam pellentesque nec nam. Mauris nunc congue nisi vitae suscipit tellus mauris. Eget magna fermentum iaculis eu. Mi in nulla posuere sollicitudin. Nibh mauris cursus mattis molestie a iaculis at erat pellentesque. Nam libero justo laoreet sit amet. Aliquam faucibus purus in massa. Velit ut tortor pretium viverra suspendisse potenti nullam ac.
</div>
well removed the div from ur table!
I am not quite sure how angular works, but here is the correct way you should implement a collapsible row; just add a new row and a <td colspan="100"> so that this cell expands to the full table width and insert your content there:
<tr>
<td colspan="100">
<div class="box">
your markup here
</div>
</td>
</tr>
Please refer the below URL for the complete reference for your( #FanaticTyp ) expandable tableview.
https://datatables.net/blog/2014-10-02
Script
/* Formatting function for row details - modify as you need */
function format ( d ) {
// `d` is the original data object for the row
return '<div class="slider">'+
'<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
'<tr>'+
'<td>Full name:</td>'+
'<td>'+d.name+'</td>'+
'</tr>'+
'<tr>'+
'<td>Extension number:</td>'+
'<td>'+d.extn+'</td>'+
'</tr>'+
'<tr>'+
'<td>Extra info:</td>'+
'<td>And any further details here (images etc)...</td>'+
'</tr>'+
'</table>'+
'</div>';
}
$(document).ready(function() {
var table = $('#example').DataTable( {
"ajax": "/examples/ajax/data/objects.txt",
"columns": [
{
"class": 'details-control',
"orderable": false,
"data": null,
"defaultContent": ''
},
{ "data": "name" },
{ "data": "position" },
{ "data": "office" },
{ "data": "salary" }
],
"order": [[1, 'asc']]
} );
// Add event listener for opening and closing details
$('#example tbody').on('click', 'td.details-control', function () {
var tr = $(this).closest('tr');
var row = table.row( tr );
if ( row.child.isShown() ) {
// This row is already open - close it
$('div.slider', row.child()).slideUp( function () {
row.child.hide();
tr.removeClass('shown');
} );
}
else {
// Open this row
row.child( format(row.data()), 'no-padding' ).show();
tr.addClass('shown');
$('div.slider', row.child()).slideDown();
}
} );
} );
Expanded View Design
<div class="slider">
... Data to be shown ...
</div>
<style>
div.slider {
display: none;
}
td.details-control {
background: url('/examples/resources/details_open.png') no-repeat center center;
cursor: pointer;
}
tr.shown td.details-control {
background: url('/examples/resources/details_close.png') no-repeat center center;
}
div.slider {
display: none;
}
table.dataTable tbody td.no-padding {
padding: 0;
}
</style>

Adding table space in bootstrap

I have a video slider and I use bootstrap for this. Now I've inserted a table within the slider(carousel). It works perfectly but I'm changing the layout. The picture below is the layout I want. I've managed to put the background. The problem is I can't insert a space between the columns of the description. How can I insert space in each of the column?
.rowTwo{
background-color: #491f43;
}
.carousel-control.left, .carousel-control.right {
background-image: none
}
h1{
color: #ffffff;
padding: 0px;
}
.txt_txt{
color: #ffffff;
font-size: 10pt;
padding: 0px;
line-height: 0px;
}
body
<div class="item active">
<table class="table table-bordered">
<tr>
<td align="center"><iframe src="https://www.youtube.com/embed//9cVusLdlC8U"/>?html5=1&wmode=transparent" style="border: 10px solid #2C2B2B; width:265px; height: 185px;"></iframe></td>
<td align="center"><iframe src="https://www.youtube.com/embed//9cVusLdlC8U"/>?html5=1&wmode=transparent" style="border: 10px solid #2C2B2B; width:265px; height: 185px;"></iframe></td>
<td align="center"><iframe src="https://www.youtube.com/embed//9cVusLdlC8U"/>?html5=1&wmode=transparent" style="border: 10px solid #2C2B2B; width:265px; height: 185px;"></iframe></td>
</tr>
<tr>
<td class="rowTwo">
<h1>Video Title<h1>
<span class="txt_txt">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc interdum, nunc sit amet condimentum aliquam, elit nulla tincidunt urna, quis dapibus augue ligula sed neque. Proin sit amet turpis at dui ultricies imperdiet. Morbi egestas augue at risus congue egestas. Morbi a egestas ante. Donec eget magna dui.</span>
</td>
<td class="rowTwo">
<h1>Video Title<h1>
<span class="txt_txt">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc interdum, nunc sit amet condimentum aliquam, elit nulla tincidunt urna, quis dapibus augue ligula sed neque. Proin sit amet turpis at dui ultricies imperdiet. Morbi egestas augue at risus congue egestas. Morbi a egestas ante. Donec eget magna dui.</span>
</td>
<td class="rowTwo">
<h1>Video Title<h1>
<span class="txt_txt">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc interdum, nunc sit amet condimentum aliquam, elit nulla tincidunt urna, quis dapibus augue ligula sed neque. Proin sit amet turpis at dui ultricies imperdiet. Morbi egestas augue at risus congue egestas. Morbi a egestas ante. Donec eget magna dui.</span>
</td>
</table>
</div>
preview site
Don't know if this will work. but you can have something like this
<div class="item active">
<div class="col-lg-4 col-md-4 col-xs-12 col-sm-12">
<div class="col-lg-12 col-sm-12" style="padding:0px">
<iframe src="https://www.youtube.com/embed//9cVusLdlC8U"/>?html5=1&wmode=transparent" style="border: 10px solid #2C2B2B; width:100%; height: 185px;"></iframe>
</div>
<div class="col-lg-12 col-sm-12" >
<h1>Video Title<h1>
<span class="txt_txt">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc interdum, nunc sit amet condimentum aliquam, elit nulla tincidunt urna, quis dapibus augue ligula sed neque. Proin sit amet turpis at dui ultricies imperdiet. Morbi egestas augue at risus congue egestas. Morbi a egestas ante. Donec eget magna dui.</span>
</div>
</div>
<div class="col-lg-4 col-md-4 col-xs-12 col-sm-12">
<div class="col-lg-12 col-sm-12" style="padding:0px">
<iframe src="https://www.youtube.com/embed//9cVusLdlC8U"/>?html5=1&wmode=transparent" style="border: 10px solid #2C2B2B; width:100%; height: 185px;"></iframe>
</div>
<div class="col-lg-12 col-sm-12" >
<h1>Video Title<h1>
<span class="txt_txt">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc interdum, nunc sit amet condimentum aliquam, elit nulla tincidunt urna, quis dapibus augue ligula sed neque. Proin sit amet turpis at dui ultricies imperdiet. Morbi egestas augue at risus congue egestas. Morbi a egestas ante. Donec eget magna dui.</span>
</div>
</div>
<div class="col-lg-4 col-md-4 col-xs-12 col-sm-12">
<div class="col-lg-12 col-sm-12" style="padding:0px">
<iframe src="https://www.youtube.com/embed//9cVusLdlC8U"/>?html5=1&wmode=transparent" style="border: 10px solid #2C2B2B; width:100%; height: 185px;"></iframe>
</div>
<div class="col-lg-12 col-sm-12" >
<h1>Video Title<h1>
<span class="txt_txt">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc interdum, nunc sit amet condimentum aliquam, elit nulla tincidunt urna, quis dapibus augue ligula sed neque. Proin sit amet turpis at dui ultricies imperdiet. Morbi egestas augue at risus congue egestas. Morbi a egestas ante. Donec eget magna dui.</span>
</div>
</div>
</div>
This puts space between each of the table data cells, coming close to what you are trying to achieve, without all the extra styling.
table {
background-color: transparent;
border-spacing: 30px !important;
border-collapse: separate;
}
td {
border: 2px solid black;
}
<div class="item active">
<table class="table table-bordered">
<tr>
<td align="center">
<iframe src="https://www.youtube.com/embed//9cVusLdlC8U"/>?html5=1&wmode=transparent" style="border: 10px solid #2C2B2B; width:265px; height: 185px;"></iframe>
</td>
<td align="center">
<iframe src="https://www.youtube.com/embed//9cVusLdlC8U"/>?html5=1&wmode=transparent" style="border: 10px solid #2C2B2B; width:265px; height: 185px;"></iframe>
</td>
<td align="center">
<iframe src="https://www.youtube.com/embed//9cVusLdlC8U"/>?html5=1&wmode=transparent" style="border: 10px solid #2C2B2B; width:265px; height: 185px;"></iframe>
</td>
</tr>
<tr>
<td class="rowTwo">
<h1>Video Title<h1>
<span class="txt_txt">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc interdum, nunc sit amet condimentum aliquam, elit nulla tincidunt urna, quis dapibus augue ligula sed neque. Proin sit amet turpis at dui ultricies imperdiet. Morbi egestas augue at risus congue egestas. Morbi a egestas ante. Donec eget magna dui.</span>
</td>
<td class="rowTwo">
<h1>Video Title<h1>
<span class="txt_txt">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc interdum, nunc sit amet condimentum aliquam, elit nulla tincidunt urna, quis dapibus augue ligula sed neque. Proin sit amet turpis at dui ultricies imperdiet. Morbi egestas augue at risus congue egestas. Morbi a egestas ante. Donec eget magna dui.</span>
</td>
<td class="rowTwo">
<h1>Video Title<h1>
<span class="txt_txt">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc interdum, nunc sit amet condimentum aliquam, elit nulla tincidunt urna, quis dapibus augue ligula sed neque. Proin sit amet turpis at dui ultricies imperdiet. Morbi egestas augue at risus congue egestas. Morbi a egestas ante. Donec eget magna dui.</span>
</td>
</table>
</div>