当打印多个页面时,它会在两个页面之间打破表格

时间:2010-01-18 14:20:25

标签: html css printing

我遇到了一个页面问题,因为它超过一页它打破了一个表,所以它将打印成两页。 我需要阻止这种情况发生,但我不知道如何发生。 我试过了

table { page-break-inside:auto }
tr    { page-break-inside:avoid; page-break-after:auto }

我在这里看到了另一个问题但到目前为止没有运气。

我正在研究IE7,但它必须主要用于IE6,IE7,IE8以及其他可能的用途。

有什么建议吗?

非常感谢。


CSS

    /*Universal selector:
This rule set will be applied to every element in a document:*/
*
{
    margin:auto;
    padding:auto;
    /*text-align:center;*/
    font-size:1em;
    }

/*The folowing rule will help to minimaze the differences between browesers*/
h1,h2,h3,h4,h5,h6,pre,code,address,caption,cite,code,em,strong,th {font-weight:normal; font-style:normal;}
ul,ol {list-style:none;}
img {border:none;}
caption,th {text-align:left;}

table {
border-spacing:0;
font-size:1em; 
font-weight:normal; 
font-style:normal; 
font-family:Times New Roman;
page-break-inside:avoid;

}
tr{ 
    page-break-inside:avoid; 
    page-break-after:auto 
}

.divTitle{
        margin:10px;
    }
}
.title
{
    font-weight:bold;
    color:#0076BF;
    font-size:1.4em;
    font-family:Times New Roman;    
    }

.divContainer
{   
    margin:10px;
    background-color:#C7D8EE;
    border:2px solid #0076BF;
    text-align:left;
    overflow:visible;   
    }

    .tableContainer
{
    color:#0076BF;
    margin: -10px 0px -10px 0px;
    border-spacing: 10px;
    empty-cells:show;
    width:90%;

    }   

    .tableContainer tr td{
     white-space:nowrap;
    }

    .tableContainerRow2{
    background-color:white;
    border:2px solid #0076BF;

    }

.divBlueBarTitle{
        margin:15px 10px -7px 10px;

        background-color:#0076BF;
    }
.divBlueBarTitle font{
    font-size:1.2em;
    font-family:Times New Roman; 
    font-weight:bold;
    color:white;
    text-indent:10px;
}
.divContainerWhite
{   
    margin:15px 10px 0px 10px;
    background-color:white;
    text-align:left;


    }
    .tableContainerWhite
{
    color:#0076BF;
    margin: 0px 0px 0px -10px;
    border-spacing: 10px;
    width:90%;

    }   

  .tableContainerWhite td{
     white-space:nowrap;
    }


.footer {
    margin-top:40px;
    padding-bottom:20px;
    font-family: Arial, Helvetica, sans-serif;
    color: #303030;
    line-height: normal;
    font-size:smaller;
    text-align:right;
    width:95%;
}

HTML

  <body>
  <div class="divTitle">
    <font class="title"> Maternity  Diary Event</font>
</div>
    <!--Maternity Diary Event-->
  <div class="divContainer">
      <table class="tableContainer" cellspacing="10px">
          <tr>
              <td>NHS Number</td>
              <td>&#160;</td>
              <td>Date of Visit</td>
              <td>&#160;</td>
              <td colspan="3">Care Time Started</td>
              <td>&#160;</td>
              <td>&#160;</td>
              <td rowspan="2" style="font-weight:bold;vertical-align:middle;">Tick when<br/> care starts</td>
          </tr>
           <tr >
              <td width="90" class="tableContainerRow2">&#160;
              <xsl:value-of select="//MaternityDiaryEvent/NHSNumber"/>
              </td>
              <td >&#160;</td>
              <td width="80" class="tableContainerRow2">&#160;12/12/09</td>
              <td >&#160;</td>
              <td width="40" class="tableContainerRow2">&#160;12</td>
              <td  width="5">:</td>
              <td width="40" class="tableContainerRow2">&#160;10</td>                         
              <td >&#160;</td>
              <td style="text-align:right" >&#160;&#9745;</td>
          </tr>
      </table>
      <table class="tableContainer" cellspacing="10px" >
          <tr>
              <td></td>
              <td>Initials</td>
              <td>Surname</td>
          </tr>
          <tr>
              <td width="80" style="font-weight:bold;">Midwife</td>
              <td width="50" class="tableContainerRow2">&#160;</td>
              <td class="tableContainerRow2">&#160;</td>
          </tr>
          <tr>
              <td></td>
              <td>Initials</td>
              <td>Surname</td>
          </tr>
          <tr>
              <td style="font-weight:bold;">Doctor</td>
              <td class="tableContainerRow2">&#160;</td>
              <td class="tableContainerRow2">&#160;</td>
          </tr>
      </table>
      <table class="tableContainer" cellspacing="10px" >
          <tr>
             <td width="250">Forename</td>
             <td>Surname</td>
         </tr>
          <tr>
             <td class="tableContainerRow2">&#160;</td>
             <td class="tableContainerRow2">&#160;</td>
        </tr>
     </table>
     <table class="tableContainer" cellspacing="10px" style="margin-bottom:10px;" >
        <tr>
          <td width="90">Date of Birth</td>
          <td width="150"></td>
          <td width="100">Casenote No:</td>
          <td></td>
      </tr>
      <tr>
          <td class="tableContainerRow2">&#160;</td>
          <td></td>
          <td class="tableContainerRow2">&#160;</td>
          <td></td>
          </tr>
    </table>
 </div>
      <!--Site Visit-->
       <div class="divBlueBarTitle">
       <font>SITE VISIT</font>
      </div>
      <div class="divContainer">
      <table class="tableContainer" cellspacing="10px" style="margin-bottom:10px;">
          <tr>
            <td>Home</td>
            <td>&#160;&#9745;</td>
            <td>Blake Maty Centre</td>
            <td>&#160;&#9745;</td>
            <td>&#160;</td>
            <td>&#160;</td>
          </tr>
          <tr>
            <td>Consultant ANC</td>
            <td>&#160;&#9745;</td>
            <td>Grange Maty Centre</td>
            <td>&#160;&#9745;</td>
            <td>&#160;</td>
            <td>&#160;</td>
          </tr>
          <tr>
            <td>Midwifery ANC</td>
            <td>&#160;&#9745;</td>
            <td>MRMC/B5</td>
            <td>&#160;&#9745;</td>
            <td></td>
            <td></td>
          </tr>
          <tr>
            <td>Day assessment Unit</td>
            <td>&#160;&#9745;</td>
            <td>Ports Maty Centre SMH</td>
            <td>&#160;&#9745;</td>
            <td></td>
            <td></td>
          </tr>
          <tr>
            <td>Labour Ward</td>
            <td>&#160;&#9745;</td>
            <td>Posnatal Ward</td>
            <td>&#160;&#9745;</td>
            <td></td>
            <td></td>
          </tr>
          <tr>
            <td>Antenatal Ward</td>
            <td>&#160;&#9745;</td>
            <td>Telephone Assessment</td>
            <td>&#160;&#9745;</td>
            <td>Other(give reason below)</td>
            <td>&#160;&#9745;</td>
          </tr>
          <tr>
            <td class="tableContainerRow2" colspan="6" rowspan="2">&#160;</td>
          </tr>  
         </table>
      </div>
      <div class="divContainerWhite">
          <table class="tableContainerWhite" cellspacing="10px" style="font-size:1.1em;">
            <tr>
                <td style="text-decoration:underline;font-weight:bold;white-space:nowrap;">Reason for Contact Booking:</td>
                <td>&#160;</td>
                <td width="150" style="font-weight:bold;">Gestation:&#160;Weeks:</td>
                <td width="30" class="tableContainerRow2">&#160;</td>
                <td width="50" style="font-weight:bold;">Days:</td>
                <td width="30" class="tableContainerRow2">&#160;</td>
                <td >&#160;</td>
            </tr> 
          </table>
          <table  class="tableContainerWhite" cellspacing="10px">
              <tr>
                  <td >Choice of Birth Offered</td>
                  <td>&#160;&#9745;</td>
                  <td >Domestic Violence Identified</td>
                  <td>&#160;&#9745;</td>
                  <td >Late Booker (&gt;&#160;11Wks&#160;6&#160;Days)</td>
                  <td>&#160;&#9745;</td>
              </tr>
              <tr>
                  <td style="white-space:nowrap">Contact Number Provided</td>
                  <td>&#160;&#9745;</td>
                  <td style="white-space:nowrap">Safeguarding Children identified</td>
                  <td>&#160;&#9745;</td>
                  <td>&#160;</td>
                  <td>&#160;</td>
              </tr>
          </table>
      </div>
      <div  class="divContainer">
      <table  class="tableContainer" cellspacing="10px">
      <tr>
        <td colspan="4" style="font-size:1.1em;text-decoration:underline;font-weight:bold;">Reason For Late Booking</td>
      </tr>
      <tr>
        <td width="200">Woman booked herself late</td>
        <td>&#160;&#9745;</td>
        <td colspan="4" style="white-space:nowrap;">&#160;&#9745;&#160;Other (give reason below)</td>

      </tr>
      <tr>
          <td>Recently moved to area</td>
          <td>&#160;&#9745;</td>
          <td rowspan="3" colspan="5" class="tableContainerRow2" >&#160;</td>
      </tr>
      <tr>
          <td>Transferred from another hospital</td>
          <td>&#160;&#9745;</td>
      </tr>
      <tr>
          <td>Late booking by Midwife</td>
          <td>&#160;&#9745;</td>

      </tr>
      <tr>
          <td>Intrapartum</td>
          <td>&#160;&#9745;</td>
          <td>Posnatal Admission</td>
          <td colspan="4">&#160;&#9745;</td>

      </tr>
      <tr>
          <td>Antenatal Admision</td>
          <td>&#160;&#9745;</td>
          <td>Intrauterine Transfer</td>
          <td colspan="4">&#160;&#9745;</td>
      </tr>
      <tr>
          <td >Antenatal Check Routine</td>
          <td >&#160;&#9745;</td>
          <td  style="white-space:nowrap;font-weight:bold;">Gestation:&#160;Weeks:</td>
          <td width="30" class="tableContainerRow2">&#160;</td>
          <td  style="font-weight:bold;">Days:</td>
          <td width="30" class="tableContainerRow2">&#160;</td>
          <td >&#160;</td>
      </tr>
          <tr>
            <td>Postnatal Check Routine</td>
            <td>&#160;&#9745;</td>
            <td colspan="2">Postnatal Check Other</td>
            <td>&#160;&#9745;</td>
            <td>Day</td>
            <td width="30" class="tableContainerRow2">&#160;</td>
            </tr>
        </table>
        <table class="tableContainer" cellspacing="10px">
          <tr>
            <td width="20%">Details</td>
            <td class="tableContainerRow2">&#160;</td>
          </tr>
        </table>
        <table class="tableContainer" cellspacing="10px">
          <tr>
            <td style="white-space:nowrap">Consultant Appt Made</td>
            <td>YES</td>
            <td>&#160;&#9745;</td>
            <td>NO</td>
            <td>&#160;&#9745;</td>
            <td width="50%"></td>
            </tr>
        </table>
      </div>
      <div class="divContainerWhite">
        <table  class="tableContainerWhite" cellspacing="10px">
            <tr>
                <td style="text-decoration:underline;font-size:1.1em;font-weight:bold;">Baby</td>
                <td>Routine Check:</td>
                <td>&#160;&#9745;</td>
                <td>Other Check</td>
                <td>&#160;&#9745;</td>
                <td>Day</td>
                <td width="30" class="tableContainerRow2">&#160;</td>
                <td>&#160;</td>
            </tr> 
            <tr>
                <td colspan="9">Details</td>
            </tr>
            <tr>
                <td colspan="9" class="tableContainerRow2">&#160;</td>
            </tr>
        </table>
        <table  class="tableContainerWhite" cellspacing="10px">
            <tr>
                <td colspan="6" style="font-size:1.1em;font-weight:bold">PUK</td>
            </tr>
            <tr>
                <td>Weight</td>
                <td>&#160;&#9745;</td>
                <td >SBR</td>
                <td>&#160;&#9745;</td>
                <td >&#160;</td>
                <td>&#160;</td>
            </tr>
            <tr>
                <td style="white-space:nowrap">Feeding Advice</td>
                <td>&#160;&#9745;</td>
                <td>Jaundice</td>
                <td>&#160;&#9745;</td>
                <td>&#160;&#9745;</td>
                <td>TICK ON LEAVING LOCATION</td>
            </tr>
        </table>
      </div>

    <!--Footer-->
    <div class="footer">
      © 2009 Graphnet Health Ltd. All rights reserved. | Disclaimer
    </div>

  </body>

1 个答案:

答案 0 :(得分:1)

如果它适合单个页面并且您始终希望它在单个页面上,那么我会尝试指定page-break-before: always。这可能会强制2页,当它可能适合一个,但它应该始终将表保持在一个页面上,只要它适合。