How to make
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
<th>d</th>
<th>e</th>
</tr>
always printable on every page.
My View
<style>
#page { margin: 150px 50px; }
#header { position: fixed; left: 0px; top: -100px; right: 0px; height: 50px; text-align: center; }
#footer { position: fixed; left: 0px; bottom: -180px; right: 0px; height: 150px; text-align: center; }
#footer .page:after { content: counter(page, upper-roman); }
</style>
<div id="header">
<h1>Tittle</h1>
</div>
<div id="content">
<?php
echo"<table class='gridtable'>";
?>
<table width="100%" page-break-inside: auto;>
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
<th>d</th>
<th>e</th>
</tr>
<?php
$num = 0;
foreach($result as $key=>$val){
$num++;
echo"<tr>
<td>".$a."</td>".
"<td>".$val['b']."</td>".
"<td>".$val['c']."</td>".
"<td>".$val['d']."</td>".
"<td>".$val['e']."</td>".
"</tr>";
}
?>
</table>
<?php
echo"</table>";
?>
</div>
<script type="text/php">
if ( isset($pdf) ) {
$font = Font_Metrics::get_font("helvetica", "bold");
$pdf->page_text(280, 780, "Page {PAGE_NUM} of {PAGE_COUNT}", $font, 10, array(0,0,0));
}
</script>
For Example, Here is my PDF after i downloaded
1st page :
| Title 1 | Tittle 2 | Tittle 3 |
| row 1 | row 1 | row 1 |
2nd page :
| row 2 | row 2 | row 2 |
How to make 2nd page like this :
| Title 1 | Tittle 2 | Tittle 3 |
| row 2 | row 2 | row 2 |
I want the Tittle always printed on top every page. Thank You
In recent versions of DOMPDF (e.g., version 0.5.2 or later, I believe), you can wrap your rows containing your table headers in a THEAD.
Change your view to:
<table width="100%" page-break-inside: auto;>
<thead>
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
<th>d</th>
<th>e</th>
</tr>
<thead>
This should do the trick. There is one case where it fails: if your table is rendered so that it breaks after your thead but before any data rows are rendered, the thead will not show up on the next page. If the table breaks across yet another page, the thead will show up on the subsequent pages.
Related
I want to display a kind of competitions results table. Each row has a participant name, followed by several cells representing participant results in last competitions (say, the competitions take place once per week). Something like this:
User name Aug 1 Aug 8 Aug 15
John Doe 1 10 100
Jane Doe 100 10 1
The table may become very wide if many columns are present. In such a case, I want the oldest columns to be hidden, so that only a few most recent are visible, and the table does not overflow the available space. The user name columns should always be visible.
The "borderline" cells can be "cut" like this:
User name g 1 Aug 8 Aug 15
John Doe 1 10 100
Jane Doe 00 10 1
...or they can be completely invisible, both variants are acceptable to me.
It is possible to achieve this with pure css?
For just one line, I've achieved it without a table, using display: flex together with direction: rtl for the 'columns' only:
https://jsfiddle.net/fo2Ldk3n/
.outer {
width: 350px;
display: flex;
justify-content: flex-right;
border: 1px solid black;
}
.header {
white-space: nowrap;
margin-right: 10px;
}
.line-box {
direction: rtl;
overflow: hidden;
white-space: nowrap;
}
.line {
padding-right: 10px;
display: inline;
white-space: nowrap;
}
<div class="outer">
<div class="header">
User Name
</div>
<div class="line-box">
<div class="line">
2223 +1
</div>
<div class="line">
10
</div>
<div class="line">
100
</div>
<div class="line">
1
</div>
<div class="line">
10
</div>
<div class="line">
100
</div>
<div class="line">
1
</div>
<div class="line">
10
</div>
<div class="line">
100
</div>
<div class="line">
1
</div>
</div>
</div>
However, this obviously fails for several rows, because the numbers will not be aligned into columns:
I've tried to use colgroup and set display: rtl etc. for the results col, but it would not work.
Also note that direction: rtl results in wrong order of 'words' within a cell (see 1+ 2223, which should be 2223 +1). The latter is not really a big problem, as I will mostly have only numbers in the cells, so it's ok if the solution has this problem. But it'll be better if it does not.
I've got it. The key is to use table wrapped into div with direction: rtl, this gives cells going from right to left and overflowing to the left. And use position: absolute for user names.
An additional direction: ltr on td even makes cell content render in correct direction.
.outer {
width: 300px;
border: 1px solid black;
position: relative;
direction: rtl;
overflow: hidden;
}
.table {
white-space: nowrap;
}
.row td {
direction: ltr;
}
.header {
position: absolute;
left: 0;
background: white;
padding-right: 10px;
}
<div class="outer">
<table class="table">
<tr class="row">
<td>1 + 100</td>
<td>100</td>
<td>1000</td>
<td>1</td>
<td>10</td>
<td>100</td>
<td>1000</td>
<td>1</td>
<td>100</td>
<td>1000</td>
<td>1</td>
<td>10</td>
<td>100</td>
<td>1000</td>
<td>1</td>
<td>10</td>
<td>100</td>
<td>1000</td>
<td class="header">User name</td>
</tr>
<tr class="row">
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>10</td>
<td>100</td>
<td>1000</td>
<td>1</td>
<td>100</td>
<td>1000</td>
<td>1</td>
<td>10</td>
<td>100</td>
<td>1000</td>
<td>1</td>
<td>10</td>
<td>100</td>
<td>1000</td>
<td class="header">Long long user name</td>
</tr>
</table>
</div>
The user name cells have different widths, but this seems to me.
I need to show a Group Title on one line, then a Personal Title on the second line and then a vertical list of peoples names under that in nested tables.
I need to show four columns on each row.
I.e. here is an example of what I want
IBM DELL IBM DELL
President President President President
Mr A Mr D Mr A Mr D
Mr B Mr E .. ..
Mr C Mr F
etc..
How to set up HTML for this?
well if you want plain HTML try this code
try adding tr, th, td tags for more rows and columns
<!DOCTYPE html>
<html>
<head>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body>
<table>
<tr>
<th>IBM</th>
<th>DELL</th>
<th>some other</th>
</tr>
<tr>
<td>President</td>
<td>President</td>
<td>President</td>
</tr>
<tr>
<td>Mr A</td>
<td>Mr D</td>
<td>Mr someguy</td>
</tr>
<tr>
<td>Mr B</td>
<td>Mr E</td>
<td>Mr someguy</td>
</tr></table>
</body>
</html>
I have a table html table which has a column named "address". The address contains very long strings. What I want is I only want to show first 2 or 3 words of the address and when I hover over it, it should show full address. How can I do this with html table?
Solution:
Use table-layout: fixed so that your table columns maintain fixed size
Wrap the content inside div elements and manipulate width and overflow properties
/*
* fixed table layout
*/
table {
table-layout: fixed;
width: 400px;
font: larger monospace;
border-collapse: collapse;
}
th:nth-child(1) {
width: 20%;
}
th:nth-child(3) {
width: 20%;
}
/*
* inline-block elements expand as much as content, even more than 100% of parent
* relative position makes z-index work
* explicit width and nowrap makes overflow work
*/
div {
display: inline-block;
position: relative;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
vertical-align: top;
}
/*
* higher z-index brings element to front
* auto width cancels the overflow
*/
div:hover {
z-index: 1;
width: auto;
background-color: #FFFFCC;
}
<table border="1">
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
<tr>
<td><div>John Smith</div></td>
<td><div>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div></td>
<td><div>1-234-567890</div></td>
</tr>
<tr>
<td><div>Jane Doe</div></td>
<td><div>Suspendisse lacinia, nunc sed luctus egestas, dolor enim vehicula augue.</div></td>
<td><div>1-234-567890</div></td>
</tr>
</tbody>
</table>
.cell {
max-width: 50px; /* tweak me please */
white-space : nowrap;
overflow : hidden;
}
.expand-small-on-hover:hover {
max-width : 200px;
text-overflow: ellipsis;
}
.expand-maximum-on-hover:hover {
max-width : initial;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table border="1">
<thead>
<tr>
<th>
ID
</th>
<th>
Adress
</th>
<th>
Comment
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
1
</td>
<td class="cell expand-maximum-on-hover">
A very, very long adress that cannot be showed entirely
</td>
<td class="cell expand-small-on-hover">
A very, very long comment to add more information to the row it belongs to.
</td>
</tr>
</tbody>
</table>
You might begin from there, this is an example of how to use max-width combined with overflow : hidden.
Pass hover the adress cell to see the result
Using Tootips gives a solution,
<html>
<table border="1" >
<tr>
<td>A</td>
<td><abbr title="Ab df df dfdf df dfdkjf sdfk dfdf">Ab df df</abbr> </td>
</tr>
<tr>
<td>B</td>
<td><abbr title="Bb df df dfdf df dfdkjf sdfk dfdf">Bb df df</abbr> </td>
</tr>
</table>
</html>
This is the code sample of a simple list display with a scroll button..It is working good. But now i want to freeze first row..that is the header..Can you please help me..
<div id="user">
<table class="user_list" frame="box" bordercolor="#c1a3cf"
border="1" cellspacing="3" cellpadding="3">
<thead>
<tr>
<th style="padding-top:15px;"> Nr. </th>
<th style="padding-top:15px;"> Concession Nr. </th>
<th style="padding-top:15px;"> Action Performed </th>
<th style="padding-top:15px;"> Action by </th>
<th style="padding-top:15px;"> Action on </th>
</tr>
</thead>
<tbody>
<?php $result = get_user_actionlog($seite,$entries);
if($seite == 1) {
$number = 0;
} else {
$number = ($seite-1) * $entries;
}
while($record = odbc_fetch_array($result)) { ?>
<tr>
<td width="25" class="rtodata"><?php $number += 1;
echo $number;?></td>
<td width="150" class="rtodata"><?php echo $record['concession']; ?> </td>
<td width="400" class="rtodata"><?php echo $record['action_performed'];?></td>
<td width="75" class="rtodata"><?php echo $record['action_by'];?></td>
<td width="100" class="rtodata"><?php echo $record['action_on'];?></td>
</tr>
<?php }?>
</tbody>
</table>
</div>
and in my CSS file,
#user {width: 900px;height:800px;overflow:auto;}
EDIT:-
scrollable table with fixed header works perfectly in IE 6.0 nad in Firefox but not in IE 7.0. If any of you champs can update that...
You can do this by adding a class to the <thead> and using position: fixed; You'll need to add some padding to your div to make it display as you wish.
Example for you here.
IE isn't good at supporting anything scrolling tables. Editing a table in this way is rarely a good idea in any case. You can have one table with your TH wrapped in a div, then the rest of your info in another table, with another div with overflow auto
Another example.
It's not perfect as you have a lot on HTML visual attributes, you should get rid of those and use CSS only. But this is the basic functionality, it should work in all browsers.
Surround the table with divs with outer and then innera..check the css
.outer {
position:relative;
padding:4em 0 3em 0;
width:54em;
background:bottom;
margin:0 auto 3em auto;
}
.innera {
overflow:auto;
width:54em;
height:9.6em;
background:#eee;
border:2px gray;
}
.outer thead tr {
position:absolute;
top:2em;
height:1.5em;
left:0;
}
.outer th, .outer td {
width:10em;
text-align:left;
I tested the code and it is working. Tested in IE 6.0,7.0 ++ .The code is from internet:-)
I'm new to html and I'm working on designing my website. I made a table that WAS center aligned until I put a scroll bar on it. Now I can't get the table to center align unless I take out the scroll bar. I'll show you what I have so far:
<div style="overflow: auto; height: 86px; width: 750px;">
<table
style="height: 86px; margin-left: auto; margin-right: auto; width: 750px; text-align: left;"
border-style:="" hidden;="" cellpadding="2" cellspacing="2">
<tbody>
TABLE CONTENT with multiple rows and two columns.
</tbody>
</table>
</div>
I tried several different approaches and still no luck. It seems like it shouldn't be this hard, so I figure I'm overlooking some small but important detail. Any help would greatly be appreciated.
Move the "margin-left: auto; margin-right: auto" styles to the div instead of the table. Also, your div and table are the same size, so there won't be a scrollbar.
<div style="overflow: auto; height: 86px; width: 500px;margin-left: auto; margin-right: auto; ">
<table style="height: 86px; width: 750px; text-align: left;" border-style:="" hidden;="" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td>1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 </td>
<td>2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 </td>
</tr>
<tr>
<td>3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 </td>
<td>4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 </td>
</tr>
</tbody>
</table>
</div