I have a small header at the top of my page and then a table containing a decent amount of dynamic data.
The data occasionally falls right on the edge of a page break when printing. So for example.
If there are 19 or less rows in the table, it will all print on 1 page.
If there are 20 or 21 rows it will throw the entire table on the second page.
If there are 22 or more rows it the table, it will print 20 on the first page and 2 on the second page
I don't mind the 1st or 3rd scenario, but I don't care for the second. I realize this is my OCD kicking in, but it seems like someone would know of a fix for it.
This seems to only occur in Firefox. In Chrome the table will always split, around after 18 rows. IE10 seems to always split as well, also at 18 rows.
I've tried every conceivable variation of the following:
table { page-break-inside:auto }
tr { page-break-inside:avoid; page-break-after:auto }
Im using bootstrap3, if that makes a difference.
Note: You can have it all print on one page by changing the print zoom, but I cant expect my users to do that.
Note: I do realize I could do a hack like check how many rows, and if it falls in the bad range, add or remove some padding somewhere on the page. But I'd rather do it the correct way, assuming there is one.
UPDATE: I Found out this happens only when Firefox is at the 100% zoom setting. When you set it to "Shrink To Fit" it behaves as the other browsers do. IE10, even with zoom set to 100% behaves normally.
You could try to add css:
table {page-break-before: avoid;}
You can put your tr inside tag but as div doesnot support tr so you have to make structure of your table like
replace
<table>
<tr >
<td class="fixture-table-header">Location Name</td>
<td class="fixture-table-header">Fixture Type</td>
<td class="fixture-table-header">Fixture Photo</td>
<td class="fixture-table-header">Qty</td>
<td class="fixture-table-header">Input Watts</td>
<td class="fixture-table-header">Annual Hours</td>
<td class="fixture-table-header">kW</td>
<td class="fixture-table-header">Annual kWh</td>
<td class="fixture-table-header">Total Utility Incentive Avaiable</td>
<td class="fixture-table-header">Total Proposed Cost</td>
</tr>
</table>
with
<table >
<tr>
<td><div><table><tr style="page-break-inside : avoid">
<td class="fixture-table-header">Location Name</td>
<td class="fixture-table-header">Fixture Type</td>
<td class="fixture-table-header">Fixture Photo</td>
<td class="fixture-table-header">Qty</td>
<td class="fixture-table-header">Input Watts</td>
<td class="fixture-table-header">Annual Hours</td>
<td class="fixture-table-header">kW</td>
<td class="fixture-table-header">Annual kWh</td>
<td class="fixture-table-header">Total Utility Incentive Avaiable</td>
<td class="fixture-table-header">Total Proposed Cost</td>
</tr></table></div></td>
</tr>
</table>
and then add this css
#media print
{
#page {size: landscape} //optional
table { page-break-after:auto }//optional
div { page-break-inside:avoid; page-break-after:auto }
}
Related
I have a webpage at http://bikepaths.com/Armstead/GBA1.html , and I have set up an HTML table to arrange text and pictures using rowspan such that the first column has a small amount of text above a tall picture, while the second column has a tall picture above a small amount of text.
<table>
<tr>
<td>George's first memory of note was ... </td>
<td rowspan="2"><img src="image/IM-GBA1885.jpg" height="440" width="280"></td>
</tr>
<tr>
<td rowspan="2"><img src="image/IM-JBA4-GBA.jpg" height="400" width="280"> </td>
</tr>
<tr>
<td>Also he recalled watching his half brother, James Benson Armstead IV <i>[on left]</i>, go through .... </td>
</tr>
</table><br>
So 3 rows, with rowspan=2 on each of the picture cells.
This displays as desired in both Firefox and Chrome, but the MS browsers I have tried (IE11 and Edge) both display it as a simple 2-row table, leaving massive amounts of space above and below each text cell.
I know MS should be banned from creating browsers until they learn what 'following standards' means, but until that happens, is there a workaround to make this display properly in IE and Edge?
<table style="table-layout:fixed">
<tr><td></td><td></td><td></td></tr>
<tr><td colspan="3">three colunms width</td></tr>
<tr><td colspan="2">two columns width</td><td>one column</td></tr>
<tr><td colspan="1">one column</td><td colspan="1">one column</td><td colspan="1">one column</td></tr>
</table>
note that the sum of the colspan attribute values or the sum of the number of td elements in each row equals the number of td elements established by the first (hidden, because the td cells are empty) row.
go to validator.w3.org/nu and copy and paste your markup into the direct input form and then press the validate button.... the w3 validators can detect where the number of td elements and the sum of colspan attributes does not match.
I'm working on a project where I've made my phpmyadmin database spit out a set of 6 images on my webpage. I've put it into a table and this is where the trouble begins - even though it sounds easy!
I need the images to be in three's, in a horizontal line.
I will have 6 images most of the time so 3 per row with good spacing/padding etc.
I've tried a lot of things and played around with the CSS but couldn't get it to work.
Here are (respectively) the actual page and how it looks, the CSS for it and the actual code/script of the table:
Actual Page
CSS for the table: table.Evidence td {
padding:0px,10px,0px,0px;
}
Script for the table:
It looks very easy but I couldn't make it work.
Any help would be much appreciated!
I'm new so please bear with me until I get used to this.
The first thing is that if you define all 4 paddings in one command you have to seperate them with spaces.
table.Evidence td { padding:0px 10px 0px 0px; }
It also seems that you don't use the table tags right.
With an tr you are adding tan new row and with an td you are adding a new cell.
A table of 2x2 cells would look like:
<table border="1">
<tr>
<td>
1
</td>
<td>
2
</td>
</tr>
<tr>
<td>
3
</td>
<td>
4
</td>
</tr>
</table>
Your <tr></tr> tags should be after every third image, so the if in your while should be:
if($i % 3 == 0){
echo "</tr></tr>";
}
else{
echo "<td><img something...></td>";
}
Also you must have one <tr> opening tag directly after the <table> tag, and one </tr> closing tag directly before the </table> tag.
I have a page written in HTML/ASP that has a series of nested tables that I use for formatting the page the way I want it.
When the page loads however there is a white space between the two tables that is not in the code and when I inspect it in chrome it shows the code has a   character between them.
Why is this appearing in the page when it loads but it is not in the script? How can I remove it?
<table width=100% border=2 cellpadding=0>
<tr>
<table width=100%>
<tr>
<th width=10% align="right">Destination:</th>
<td width=60%>Here</td>
<td width=10% align="right">Date:</td>
<td width=20% align="left"> <%=FormatDateTime(d,2)%></td>
</tr>
</table>
</tr>
<tr>
<table width = 100%>
<tr>
<td width=2%> </td>
<td align="right">Time1:</td>
<td align="center"><%=formatTime(oRS1("time"))%></td>
<td><%=oRS1("location")%></td>
<td width=40> </td>
<td align="right">Driver</td>
<td> <%=fpn%></td>
</tr>
<tr>
</table>
I just had this same issue and here are the steps that I tried that eventually fixed it:
Cleared the cache in the browser
Cleared all browser data
Tried a different browser
None of the above worked in my case, and the phantom was not in my code (and I triple checked it!!!!), but it was obviously somewhere since it was showing in the console and other browsers:
So, (and this may not be the best way to solve this but it worked) as you can see from my console output, I added two paragraph tags above and two below (by carefully putting the cursor in front of the next element and using a carriage return and the arrow key to go back up) to get the phantom in the middle. After that I saved it, then proceeded to select and delete the two paragraph tags in the middle together (with the phantom between them). This is what finally worked, the delete of both the elements surrounding it together took the phantom with it...
Perhaps some small part of my html page became corrupted? Who knows... but if anyone else is having this issue, give this a try.
I have 2 tables one on top of the other and I would like to align their column widths exactly with each other, is there a way to do this? Tried fixed table col widths etc no joy
You can see on fiddle the columns are slightly off each other
http://jsfiddle.net/askhe/
HTML
<table class="tblresults txtblack">
<tr class="tblresultshdr bold">
<td class="col1">Company</td>
<td>Currency</td>
<td>Bid</td>
<td>Ask</td>
<td>YTD Vol</td>
</tr>
<tr>
<td class="col1">ABC</td>
<td>GBP</td>
<td>94</td>
<td>16</td>
<td>3,567,900</td>
</tr>
<tr>
<td class="col1">DEF</td>
<td>GBP</td>
<td>3</td>
<td>46</td>
<td>10,000</td>
</tr>
<tr>
<td class="col1">GHI</td>
<td>GBP</td>
<td>3</td>
<td>46</td>
<td>10,000</td>
</tr>
<tr>
<td class="col1">JKLM</td>
<td>GBP </td>
<td>7</td>
<td>46</td>
<td>56,000</td>
</tr>
</table>
<table class="tblresults txtblack margintop10">
<tr>
<td colspan="5" class="bold" >Investments</td>
</tr>
<tr>
<td class="col1">ghjk</td>
<td>GBP</td>
<td>13</td>
<td>6</td>
<td>130,000</td>
</tr>
<tr>
<td class="col1">asdsa</td>
<td>GBP</td>
<td>120</td>
<td>46</td>
<td>16,000</td>
</tr>
<tr>
<td class="col1">dfdsfsdf </td>
<td>GBP</td>
<td>1</td>
<td>4</td>
<td>13,000</td>
</tr>
</table>
CSS
table.tblresults {
width:100%;
*width:99.5%;
border: 1px solid #b9b8b8;
top: 0;
}
table.tblresults tr.tblresultshdr {background: lightgrey;}
table.tblresults tr.tblresultshdr td {padding: 6px;}
table.tblresults td {padding: 8px; border: 1px solid #b9b8b8;}
table.tblresults td.col1 {width: 70%;}
table elements where meant for scientific data, such as probes from experiments, not for actual layout:
Tables should not be used purely as a means to layout document content as this may present problems when rendering to non-visual media. Additionally, when used with graphics, these tables may force users to scroll horizontally to view a table designed on a system with a larger display. To minimize these problems, authors should use style sheets to control layout rather than tables.
While you're not using them for layout, your problem is actually a rendering/layout issue. The easiest solution to this is to merge both tables into one (jsfiddle).
If you prefer your data to be encapsulated in many little tables instead of one giant table you'll need to specify a width for almost all columns.
Why not put them in the same table? It seems they are semantically similar.
http://jsfiddle.net/askhe/5/
No need to merge tables, you can use this
table-layout: fixed;
There is a wonderful article here about it
https://css-tricks.com/fixing-tables-long-strings/
Although I agree that the solution to merge the tables is the best and simplest one in many cases, i came to the need to really have this 2 separate tables with identical columns (to make one table fixed and the 2nd scrollable)
to achieve that, I declared 2 tables with same number of columns, one with width rules (% and px), one without
Then, with Javascript, I applied the width of the ruled table to the free one:
document.getElementById("HeaderTable").style.width = document.getElementById("main").clientWidth ;
document.getElementById("tar1").style.width = document.getElementById("org1").clientWidth ;
document.getElementById("tar2").style.width = document.getElementById("org2").clientWidth ;
document.getElementById("tar3").style.width = document.getElementById("org3").clientWidth ;
document.getElementById("tar4").style.width = document.getElementById("org4").clientWidth ;
1st line fix the table width, then it's done column by column. Using .clientWidth is important, because .style.width send a percentage if it's what is applied on the ruled column.
This was almost working, but not quite. Table had a similar layout, but shifted by a few pixels. As I only needed that to be working in IE, I though I could move that with fixed values, to be as close as possible as what I wanted, so I change my code to:
document.getElementById("tar1").style.width = document.getElementById("org1").clientWidth - 9;
document.getElementById("tar2").style.width = document.getElementById("org2").clientWidth ;
document.getElementById("tar3").style.width = document.getElementById("org3").clientWidth - 10;
document.getElementById("tar4").style.width = document.getElementById("org4").clientWidth - 10;
I guess the values could be different for a different table. But what surprised me, is that it works in every major browser, independently of the zoom level
windows resize breaks the alignement, so you need to bind the function to this event. Also, this solution don't work anymore on extreme size of the table
Here is a jsfiddle, as some CSS is involved. for the moment it doesn't work on zoom, because my floating header doesn't stick to right: 0px, don't know why yet
Well, using this simple HTML snippet you can do it. well in my case i was creating pdf's from HTML, so this solution worked for me. Hope it help some one else.
<table border=0>
<tr>
<td>
<!--Insert table 1 -->
</td>
<td>
<!--Insert table 2 -->
</td>
</tr>
</table>
I'm having an impossible time getting border-collapse to work for me. The page I'm working with has a table in it. The table has 2 columns, one for a label and the other for data. Sometimes there is no data to display, but I still need to rendor the table row and label column because I have a JQuery script that might need to write data to the data column. In other words, regardless of whether there is data or not, I need to rendor the table row as a placeholder. If there is no data I want the row to collapse.
In the html below, visibility:hidden is working since I won't see the label 'Condition:', but the row doesn't collapse. I've tried looking at it in FireFox 13, Safari 5 and IE 8. All three show the same problem - the row never ccollapses even though it doesn't display anything.
#data
{
font-size: 95%;
}
#data table
{
border-collapse: collapse;
margin-top: 15px;
margin-bottom: 15px;
}
#data table td
{
padding-left: 5px;
}
<div id="data">
....
<table>
<tr style="visibility:hidden;">
<td><div class="datalabel">Condition:</div></td>
<td class="datainfo"></td>
</tr>
</table>
....
</div>
What more do I need to do to make this happen? I'd like it to be cross-browser compatible. I'm trying to support IE7 and above. I'm guessing someone is going to give me hell for using a table in the first place... ;)
The visibility property determines whether a given element is visible
or not (visibility="visible|hidden"). However, when visibility is set
to hidden, the element being hidden still occupies its same place in
the layout of the page.
Display VS Visibility
use display:none; to hide and display:block; to show
<table style="border-collapse:collapse;">
<tr style="display:none;">
<td><div class="datalabel">Condition:</div></td>
<td class="datainfo"></td>
</tr>
</table>
Note: border-collapse:collapse; is used in a situation, where you have borders specified for container and the contained and you want border to be displayed once.
<table border="0" cellpading="0" cellspacing="0">
and try to use and &nbps; or something like that, if you don't have data in a cell
something like:
<table border="0" cellpading="0" cellspacing="0">
<tr style="visibility:hidden;">
<td><div class="datalabel">Condition:</div></td>
<td class="datainfo"> </td>
</tr>
</table>