473,396 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Getting all content of <div> to print

Claus Mygind
571 512MB
When I design my pages, I am putting the content into <div> tags. For example I may have two <div> tags side by side content on left and on the right.

My problem is this, if I want to select print from the browser menu only the content visible on the screen prints. Any content which you would have to to scroll down to see is cut off.

I have created a print.css file with my other print settings to remove things like navigation elements and setting the color of the font and background to black and white respectively.
Expand|Select|Wrap|Line Numbers
  1.  /* Remove unwanted elements */
  2. #header, #nav, .noprint
  3. {
  4. display: none;
  5. }
  6.  
  7. /* Ensure the content spans the full width */
  8. #container, #container2, #content
  9. {
  10. width: 100%; margin: 0; float: none;
  11. }
  12.  
  13. /* Change text colour to black (useful for light text on a dark background) */
  14. .lighttext
  15. {
  16. color: #000
  17. }
  18.  
  19. /* Improve colour contrast of links */
  20. a:link, a:visited
  21. {
  22. color: #781351
  23. }
  24.  
  25.  .printBody 
  26.  { 
  27.     color: #000000;  
  28.     background-color: #FFFFFF;  
  29.  } 
  30.  
I would like to add the style, that would let me print the entire content of the <div> even if it is multiple pages.

Not too worried about page breaks for now, just want the content to come out.

The two side by side <div's> look like this:
Expand|Select|Wrap|Line Numbers
  1.    <div id="LeftHalf" align="center">
  2.        <table id="GeoTechTable" width="99%" align="center" border="1">
  3.             <tbody id="GeoTechBody" align="center">
  4.            <tr>
  5.                 <td class="MenuTitle" colspan="4">Geo Tech Lab Work</td>
  6.            </tr>
  7.            <tr>
  8.                  <td class="subHeading3">Job #</td>
  9.                <td class="subHeading3">Boring</td>
  10.                <td class="subHeading3">Container #</td>
  11.                <td class="subHeading3">Lab Tech</td>
  12.            </tr>
  13.        </tbody>
  14.    </table>
  15.  </div>
  16.  
  17.  <div id="RightHalf" align="center">
  18.     <table id="CMETable" width="99%" align="center" border="1">
  19.     <tbody id="CMEBody" align="center">
  20.     <tr>
  21.     <td class="MenuTitle" colspan="4">CME Lab Work</td>
  22.     </tr>
  23.     <tr>
  24.         <td class="subHeading3">Job#</td>
  25.         <td class="subHeading3">Lot/Date</td>
  26.         <td class="subHeading3">Container #</td>
  27.         <td class="subHeading3">Lab Tech</td>
  28.     </tr>
  29.    </tbody>
  30. </table>
  31. </div>
  32.  
And the styles already assigned to them looks like this:
Expand|Select|Wrap|Line Numbers
  1. #LeftHalf {
  2.     position: absolute;
  3.     white-space: nowrap; 
  4.     left: 0%; 
  5.     top: 25px;
  6.     width: 47%;
  7.     color: #333333;
  8.     padding:5px;
  9.     font-size: 10pt;
  10.     overflow: hidden;
  11.     z-index: 98;
  12. }
  13. #RightHalf {
  14.     position: absolute;
  15.     white-space: nowrap; 
  16.     left: 50%; 
  17.     top: 25px;
  18.     width: 47%;
  19.     color: #333333;
  20.     padding:5px;
  21.     font-size: 10pt;
  22.     overflow: hidden;
  23.     z-index: 98;
  24. }
  25.  
Aug 23 '10 #1

✓ answered by Claus Mygind

I can get it to work if I assign this to the id


Expand|Select|Wrap|Line Numbers
  1. #printDiv
  2. {
  3.     overflow: visible;
  4.     height: auto;
  5. }
  6.  
But then I loose my formatting of side by side for the screen definition. Where the overflow is hidden.

Expand|Select|Wrap|Line Numbers
  1. #LeftHalf {
  2.     position: absolute;
  3.     white-space: nowrap; 
  4.     left: 0%; 
  5.     top: 25px;
  6.     width: 47%;
  7.     color: #333333;
  8.     padding:5px;
  9.     font-size: 10pt;
  10.     overflow: hidden;
  11.     z-index: 98;
  12. }
  13.  
If I just leave it as a class ="printDiv", it inherits the "LeftHalf" and the print does not work. Hmmm!
Expand|Select|Wrap|Line Numbers
  1. .printDiv
  2. {
  3.     overflow: visible;
  4.     height: auto;
  5. }
  6.  

1 3186
Claus Mygind
571 512MB
I can get it to work if I assign this to the id


Expand|Select|Wrap|Line Numbers
  1. #printDiv
  2. {
  3.     overflow: visible;
  4.     height: auto;
  5. }
  6.  
But then I loose my formatting of side by side for the screen definition. Where the overflow is hidden.

Expand|Select|Wrap|Line Numbers
  1. #LeftHalf {
  2.     position: absolute;
  3.     white-space: nowrap; 
  4.     left: 0%; 
  5.     top: 25px;
  6.     width: 47%;
  7.     color: #333333;
  8.     padding:5px;
  9.     font-size: 10pt;
  10.     overflow: hidden;
  11.     z-index: 98;
  12. }
  13.  
If I just leave it as a class ="printDiv", it inherits the "LeftHalf" and the print does not work. Hmmm!
Expand|Select|Wrap|Line Numbers
  1. .printDiv
  2. {
  3.     overflow: visible;
  4.     height: auto;
  5. }
  6.  
Aug 23 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Philo | last post by:
How do I select all <div> tags except those which contain a <table> tag somewhere within them? Example XML: <********************** sample input ***********************> <txtSectionBody>...
3
by: Jens Kristensen | last post by:
I have a problem displaying a divbox containing a html-textarea - everything works fine with "normal" characters. However, when the textarea contains special chars like <P> or ' , the box fails to...
23
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
5
by: Ben Gribaudo | last post by:
Hello! I am working on revising my Web site template. The main part of the page is divided into two columns (each a <div>)--a side bar on the left and the main content area on the right. Both...
2
by: Scott Bell | last post by:
http://www.scottbell.org/sunrise/ http://www.scottbell.org/sunrise/css/v2.css On the above URL I'm trying to get a sidebar menu on the right to align with the page text except it seems to sit...
44
by: Jim M | last post by:
I have had great success with using <iframe> with overflow-y set to auto. I can get a similar look with the <iframe> tag. BUT... In all cases I need to have fixed heights. Is there a way to...
7
by: BBB | last post by:
I have a web form with a <div> section ... I have it setup so the Update/Cancel buttons are fixed at the bottom of the screen while the content of the form is in the <div> and scrolls. Nice to the...
3
by: tungchau81 | last post by:
Hi, A Modal Dialog does not allow us to highlight the text content inside <DIV> tag unless I use a <textarea> tag to display that text content. However, the situation of my software makes it...
4
by: He Shiming | last post by:
Hi, I'm wondering how can I use <DIV> to mimic a <TABLE>. In a bare <TABLE> without a width attribute, the width of the table get dynamically expanded according to the content. However, <DIV>...
8
prino
by: prino | last post by:
Hi all, I've written code (in REXX) that takes files in legacy languages (PL/I, COBOL, z/OS assembler, etc) and converts them into HTML in a format similar to what's displayed in the z/OS ISPF...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.