I am trying to implement fix header for my table in my angular 10 application. I have applied CSS and I can see that fixed header is working but it seems to hide behind the navbar when i try to scroll down. Please see the screenshot for more details . I tried manipulating the top property but doesnt seem to make a difference.
After scrolling
html table
<div class="container">
<div class="row">
<div class="col-12">
<button class="btnAddCustomer" (click)="addCustomer()"> Add Customer (Template Driven) </button>
</div>
</div>
<div class="row">
<div class="col-12">
<div *ngIf="customerDetails">
<table id="customerdetails-table" class="table table-bordered table-striped">
<thead>
<th>Customer</th>
<th>Company Name</th>
<th>Contact Name</th>
<th>Address</th>
<th>City</th>
<th>Postal Code</th>
<th>Country</th>
<th>Phone</th>
<th>View Order</th>
</thead>
<tbody>
<tr *ngFor="let custDetails of customerDetails">
<td>{{custDetails.customerId}}</td>
<td>{{custDetails.companyName}}</td>
<td>{{custDetails.contactName}}</td>
<td>{{custDetails.address}}</td>
<td>{{custDetails.city}}</td>
<td>{{custDetails.postalCode}}</td>
<td>{{custDetails.country}}</td>
<td>{{custDetails.phone}}</td>
<td>{{custDetails.customerId}}</td>
</tr>
</tbody>
</table>
<pagination [totalItems]="totalItems" [itemsPerPage] = "5" [maxSize]="maxSize" ></pagination>
</div>
</div>
</div>
</div>
CSS
table {
text-align: left;
position: relative;
}
th {
margin-top: 10px;
background: white;
position: sticky;
top: 0; /* Don't forget this, required for the stickiness */
box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.4);
}
You want the navbar to be infront of all your other HTML elements, it does not make sense to have another element overlap the navbar.
It sounds like you just want the table to be scrollable, if that's the case, put the table in a of fixed size (equal to the scrollable area that you want)
Example:
<div style = "height: 100px; width: 100px">
...your table stuff
</div>
Then add the functionality to make it so you can scroll through the table vertically by using the overflow-y property.
<div style = "height: 100px; width: 100px; overflow-y:auto">
...your table stuff
</div>
Making a div vertically scrollable using CSS
Related
I trying development a loading bar in DataTable, but in styles not working for me. I use material-design-lite.
My html
<div class="mdl-cell mdl-cell--11-col mdl-cell--8-col-tablet mdl-cell--4-col-phone mdl-shadow--8dp">
<div class="mdl-grid">
<div class="mdl-cell mdl-cell--12-col mdl-cell--8-col-tablet mdl-cell--4-col-phone" style="min-height: 300px; margin-top: 10px; cursor:pointer">
<table id="tabela">
<thead>
<tr>
<th>Id.</th>
<th>Name</th>
<th>Age</th>
<th>Phone</th>
<th>Actions</th>
</tr>
</thead>
</table>
</div>
<div class="preloader">
Carregando...
</div>
</div>
</div>
In my css, i use
.preloader {
background-color: rgba(55, 55, 55, .5);
width: 100%;
position: absolute;
}
but my preloader expand out root div
My link with jsfiddle test
It's possible make div preloader not expand out root div?
I'm having some problems on iphone while trying to show a "timeline" on iphone, the timeline is just a table with it's content.
The issue is that like if i have 30 rows on iphone there are shown just 28 while the other two are behind the footer and i'm able to show them only if i scroll not the div but entire page.
How can i set the height to the table in the way it's end on the footer start and not on the page end?
The page is build as the following (the table content is load dynamically)
<div class="container-fluid p-0">
<div class="card rounded-0" id="cardTav">
<div id="bodyTavoli" class="card-body text-center">
<div class="table-responsive tableFixHead">
<table class="table table-hover" id="tableLine" border="0" style="border: none; width: 100%; margin-bottom: 0px;">
<thead id="timehead">
<tr>
</tr>
</thead>
<tbody id="timeline">
</tbody>
</table>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
</div>
</footer>
Here is JSFiddle code (upper the container there is the nav) https://jsfiddle.net/3hvLwt6m/
Please modify your css code changes are given below
css
.tableFixHead {
overflow-y: auto;
max-height: 70vh;
}
table {
margin-bottom: 60px;
}
I think this will work try adding this in js fiddle you provided. I dont have a iphone so cant test.
you can modify css as followed..
.tableFixHead {
max-height: 70vh;
overflow-y: auto;
}
I have a table defined using bootstrap 3 and some custom css. When I resize the browser window it ends overflowing the table beyond the width of the enclosing div as shown in the picture below. I am using IE and the developers tool shows no computed table attribute affecting this behavior. I also checked the tr and td dynamically computed attributes and still no luck finding the culprit for this behavior.
Can anyone shed some light into what settings could be provoking this?
<div class="pad-top pad-side">
<div class="row">
<div class="col-lg-3">
<div class="panel panel-default" ng-show="{{reportData.PnlStatistics != undefined}}" style="height: 380px">
<div class="panel-heading">
<label>Expected In-Sample PnL Statistics</label>
</div>
<div class="panel-body" style="padding-top: 5px;">
<table class="table table-x-condensed table-striped table-hover table_nowrap" id="pnlStatisticsTable" st-safe-src="pnlStatistics"
st-table="displayedPnlStatistics">
<thead>
<tr>
<th style="width: 60%;" id="name">Name</th>
<th style="width: 20%;" id="daily">Daily</th>
<th style="width: 20%;" id="optimal">Optimal</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="data in displayedPnlStatistics">
<td style="width: 60%; padding-top: 0px; padding-bottom: 0px;">{{data.name}}</td>
<td style="width: 20%; padding-top: 0px; padding-bottom: 0px;">{{data.DailyHedge}}</td>
<td style="width: 20%; padding-top: 0px; padding-bottom: 0px;">{{data.OptimalHedge}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
The best solution I have found was to modify the enclosing div style and set a minimum width. This prevents the enclosing parent div from shrinking below the contents size and it works great.
<div class="col-lg-3" style="min-width: 350px;">
...
</div>
As we can see from the image my content overlaps with the header image and this is the code I have:
<style type="text/css" media="print">
#page {
/*size:landscape;*/
#top-center {
content: element(header);
}
#bottom-left {
content: element(footer);
}
}
div.header {
padding: 10px;
position: running(header);
}
div.footer {
display: block;
padding: 5px;
position: running(footer);
}
.pagenumber:before {
content: counter(page);
}
.pagecount:before {
content: counter(pages);
}
</style>
</head>
<div class="header">
<img src="logo.png" title="logo" width="200px"/>
</div>
<div class="content">
</div>
P.S.: Please don't close this question as duplicate as I have already searched all the questions related to the same but mine looks different as PDF is involved.
Headers and footers are established within the page margins.
So the solution is to increase the page top margin, for example:
#page {
margin-top: 50mm;
}
Method to implement header footer properly in PDF
After finding a lot on internet on different solutions and workaround, I'm finally sharing a way that works for me.
Please add these style to report container (the div in which report is rendered).
<div #scrollingContainer class="col-xxs-9 content-container" style="overflow-x: hidden;width:100%;">
</div>
// Div properties may differ
Wrap the Doc component into the table structure with thead and tfoot according to the size of your header and footer(table is wrapped inside a div).
<div style="width: 100%;">
<table style="table-layout: fixed; width: 100%;"> // Add this css to make main table fixed, child tables will still scroll
<thead class="page-break-before">
<tr>
<td>
<div style="height: 80px;"></div> // space for the respective header
</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<div> Your Data Goes Here........</div>
</td>
</tr>
</tbody>
<tfoot class="show-in-print page-break-after">
<tr>
<td>
<div style="height: 130px;"></div> // space for the respective footer
</td>
</tr>
</tfoot>
</table>
</div>
Sample Header and footer
<div class="page-break-before">
<div>A long header content...</div>
</div>
<div class=" page-break-after">
<p> A long footer content...</p>
</div>
I have a div that is scrollable horizontal and vertical. The problem is my header expands pretty far horizontal, as it is a table header that has a lot of columns. I want to be able to scroll left and right on the table but scroll vertical and keep that heading at the top always, but be able to scroll left at any time and show the rest of the heading. I've found some javascript examples online but i don't see any on how to do this inside a div, and I've tried to incorporate them but do not work.
Can anyone help me with this?
<div style = "margin:20px 0px 7px 15px">
<strong>  Audit Log:</strong>
<div style="width:750px; height:580px; border-width:1px; border-style:solid; border-color:#000; background: #bbb">
<div style="margin:20px 0px 0px 12px">
<div class="container">
<div class="heading">
<table>
<tr>
<th style="width:160px">Time:</th>
<th style="width:210px">Source:</th>
<th style="width:75px">Category:</th>
<th style="width:90px">Ssa Admin:</th>
<th style="width:85px">UserID:</th>
<th style="width:50px">Action:</th>
</tr>
</table>
</div>
<div wicket:id="repeaterContainer">
<table style="table-layout: fixed; width:505px">
<tr wicket:id="repeatingList" class="spaceUnder">
<td style="width:160px" wicket:id="time"></td>
<td style="width:220px" wicket:id="source"></td>
<td style="width:70px" wicket:id="category"></td>
<td style="width:90px" wicket:id="ssaAdmin"></td>
<td style="width:80px" wicket:id="userID"></td>
<td style="width:250px" wicket:id="action"></td>
</tr>
</table>
</div>
</div>
</div>
div.container
{
position:relative;
overflow:auto;
width:720px;
height:380px;
border-width:1px;
border-style:solid;
border-color:#000;
background: #fff;
}
div.heading
{
position: absolute;
border-bottom: 1px solid #000;
background: #bbb;
width:1250px;
}
</style>
</wicket:head>
<wicket:extend>
<script>
$('.container').scroll(function() {
$('.header').css({
'left': 1250 - $(this).scrollLeft()
});
});
</script>
<p>
<div wicket:id="tabs" class="tabpanel"></div>
</p>
</wicket:extend>
Do I understand correct, that you need just scrolling tbody and whole table is in the div?