打印页面样式设计 控制一个table显示在一页上

此页面是基于php的基础写的……

<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8" />
        <style>
            p{line-height: 0;margin: 0;}
            .h1-center{ text-align: center;font-size:28px;font-weight:bold;}
            .table-printer{ width:100%;margin:10px auto;border-collapse: collapse; border-spacing: 0;border:2px solid #000;background:#FFF;border-left: 0;border-top:0;}
            .table-printer td{border:2px solid #000;border-bottom: 0;border-right: 0;text-align: center;}
        </style>
    </head>
    <body>
        <?
        //智能分页
        $pagesize = 12;
        $lessons_array_chunk = array_chunk($lessons, $pagesize);
        ?>       
        <? $config = json_decode($paynote->config); ?>
        <? foreach ($lessons_array_chunk as $p => $les): ?>
            <div  style="margin:60px auto 0 10px;" style="height:940px;">
                <? if ($p == 0):  ?>
                    <div class="h1-center"> <? echo $team->name ?>班级点名册 </div>
                    <? if ($this->input->get('action')=='debug') echo $paynote->lesson_start_time; ?>
                    <div style="text-align: right;margin-top:6px;">有效学习周期:<? echo date('Y.m.d', $paynote->lesson_start_time) . '-' . date('Y.m.d', $paynote->lesson_end_time) ?></div>
                <? endif; ?>
                <table class="table-printer">    
                    <thead>
                        <? if ($p == 0): ?>
                            <tr>
                                <td colspan="25">
                                    <table width="100%">
                                        <tr>
                                            <th align="left">上课时间:周<? echo element($team->week, $this->base_config_model->config_item('week')) ?> <? echo sumtime($team->start_hour, $team->start_minute, $team->unit_time) ?>,时长:<? echo $team->unit_time; ?>分钟
                                                    
                                                上课地点:<? if ($classroom = $this->base_classroom_model->cache_by_id($team->classroom_id)) echo $this->base_school_model->cache_by_id($classroom->school_id)->name.$classroom->name; ?></th>
                                            <th align="right">任课老师:<? if ($teacher = $this->base_user_model->cache_by_id($team->teacher_id)) echo $teacher->name ?></th>
                                        </tr>
                                    </table> 
                                </td>
                            </tr>
                        <? endif; ?>
                        <tr>
                            <td width="40">序号</td>
							<td width="60">学号</td>
							<? if ($p == 0): ?>
								<td width="70">学费单号</td>
							<? endif; ?>
							<td width="70">姓名</td>
							<td width="100">联系电话</td>
                            <? foreach ($les as $le): ?>
                                <td style="text-align:center;">
                                    <?
                                    //时区有BUG
                                    date_default_timezone_set('PRC');
                                    if ($this->input->get('action')=='debug') echo $le->start_time;
                                    if ($le->start_time) {
                                        echo date('m.d', $le->start_time);
                                    } else {
                                        echo element($le->classify, $this->base_config_model->config_item('lesson_classify'));
                                    }
                                    ?>
                                </td> 
                            <? endforeach; ?>
                        </tr>
                    </thead>
                    <tbody>
                        <?
                        $n = 1;
                        foreach ($students as $student):
                            ?>
                            <tr>
                                <td height="30"><? echo $n ?></td>
                                <td><? echo $student->sn ?></td>
                                <? if ($p == 0): ?>
                                    <td><? if ($student->paynote_detail) echo $student->paynote_detail->pay_sn ?></td>
                                <? endif; ?>
                                <td><? echo $student->name ?></td>
                                <td>
                                    <? echo $student->mobilephone ?>
                                    <? if ($student->telephone) echo '<br/>' . $student->telephone; ?>
                                </td>
                                <? foreach ($les as $le): ?>
                                    <td> </td>
                                <? endforeach; ?>
                            </tr>
                            <?
                            $n++;
                        endforeach;
                        ?>
                    </tbody>
                    <? if ($p == 0): ?>
                        <tfoot>
                            <tr>
                                <td colspan="25" style="height:30px;text-align: left">
                                    <? echo $team->unit_price ?>元/课时,共<? echo $paynote->lesson_num ?>次课,计<? echo $paynote->price ?>元 <? if (isset($config->cailiaofei) && $config->cailiaofei) echo '(含' . $config->cailiaofei . '元材料费)'; ?>
                                </td>
                            </tr>
                        </tfoot>
                    <? endif; ?>
                </table>
                <? if ($p == 0): ?>备注:<? endif; ?>
				
            </div>
            <div style="page-break-after:always;"> <br/></div>
        <? endforeach; ?>
    </body>
</html>

【效果预览】





阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页