php - 如何使用 div 而不是表格创建页眉和页脚? PHP, HTML, CSS

标签 php html css

我有这个页眉/页脚,但问题是我正在使用的从 html 到 pdf 的转换不支持表格内的样式(即 mpdf)。我想使用 div 包装页眉和页脚,但我对这一切都是陌生的,不确定如何准确地做到这一点。

这是标题部分

<table width='100%' class='print_only_wrapper'>
  <thead class='print_only_header'>
<tr>
<td align='"($centered?"center":"right")."'class='print_only_wrapper'> The header </td>
</tr></thead>
  <tbody><tr><td>

"content goes here"

这是页 footer 分

 </td></tr></tbody>
  <tfoot class='print_only_footer'>
<tr>
<td align='".($centered?"center":"right")."'>   footer text    </td>
</tr>
</tfoot>
</table>"

最佳答案

答案在这里

Fiddle

CSS

    body
    {
        margin: 0;
    }
    #header
    {
        width: 100%;
        background: #333333;
        height: 70px;
        color: #FFFFFF;
    }
    #container
    {
        color: #000000;
        height: 350px; // later you can change this height;
    }
    #footer
    {
        width: 100%;
        background: #333333;
        height: 70px;
        color: #FFFFFF;
    }

HTML

    <div id="header">
        header
    </div>
    <div id="container">
        container
    </div>
    <div id="footer">
        footer
    </div>

关于php - 如何使用 div 而不是表格创建页眉和页脚? PHP, HTML, CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21397135/

相关文章:

php - 使用 preg_replace 的复杂正则表达式,替换不在 [ 和 ] 内的单词

javascript - 在具有相同类的 div 之间插入元素

html - 在没有 Javascript 的情况下为 CSS 关键帧 slider 创建前向/后向链接

Rails 应用程序中的 jquery 和 css : shifting a div to the left in response to a mouseover event not working

html - 登录表单太大

php - 正则表达式帮助 - Wordpress (search-regex)

php - 即使通过我的 PHP 脚本获得成功 1 后也无法在 android 中发送推送通知

PHP 错误日志记录无法通过 .htaccess 工作

html - Chrome 的 `srcset` 属性对应于哪些设备尺寸/分辨率?

html - 当我对两个图像使用绝对位置时链接不可点击(只有第一个是可点击的)