CSS   发布时间:2022-04-17  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了css – html页面中的自定义页眉和页脚大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在打印模式下将页眉和页脚放在每个页面中.我做了很多研究.

我找到了两个解决方案.但它们不是跨浏览器(我希望它能在IE,Firefox和Chrome中运行)

第一个解决方案:我在内容表的顶部和底部设置边距.然后我用固定位置写这个空间的页眉和页脚.它在Firefox中运行良好.但在IE和Chrome中并没有设定利润率.同样在Chrome中,它不会为每个页面编写页眉和页脚.

这是我的代码:

pagination.php

<!DOCTYPE HTL> 
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
    <meta name="robots" content="noindex,nofollow">
    <meta name="googlebot" content="noindex">
    <meta http-equiv="cache-control" content="no-cache">    
    <title>Brove.NET ISO Yazılımı</title>
    <link rel="stylesheet" type="text/css" href="css/pagination.css" />
</head>

<body>
    <table class="header" celLPADding="0" cellspacing="0">
      <tr>
        <td>header
        </td>
      </tr>
    </table>

    <table class="content" celLPADding="0" cellspacing="0">
      <tr>
        <td valign="top">
       content
        </td>
      </tr>
    </table>

    <table class="footer" celLPADding="0" cellspacing="0">
      <tr>
        <td>footer
        </td>
      </tr>
    </table>

</body>
</html>

pagination.css

@media screen{
    .header{
        width:768px;
        height:100px;
        border:2px solid #000;
    }

    .content{
        width:768px;
        margin-top:10px;
        margin-bottom:10px;
        height:1000px;
    }

    .footer{
        width:768px;
        height:100px;
        border:2px solid #000;
    }
}

@media print {    
    .header{
        position:fixed;
        top:0;
        left:0;
        width:768px;
        height:100px;
        border:2px solid #000;
    }

    .content{
        width:768px;
        margin-top:120px;
        margin-bottom:120px;
        height:1000px;
    }

    .footer{
        position:fixed;
        left:0;
        bottom:0;
        width:768px;
        height:100px;
        border:2px solid #000;
    }

    @page{
        margin-bottom:150px;
    }
}

这是第二个解决方案:

在此解决方案中,我使用table-header-group和table-footer-group属性.它适用于Firefox和IE.但Chrome不再理解.在打印模式下,它不会在每个页面中重复页眉和页脚.

这是另一个代码:Is there a way to get a web page header/footer printed on every page?

<style type="text/css">
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }
</style>

<body>
<table>
   <thead><tr><td>Your header goes here</td></tr></thead>
   <tfoot><tr><td>Your footer goes here</td></tr></tfoot>
   <tbody>
     <tr><td>
     Page body in here -- as long as it needs to be
     </td></tr>
   </tbody>
</table>
</body>

是否有任何黑客可以解决这个浏览器问题,或者您对我有什么建议吗?

解决方法

尝试使用div标签而不是任何表标签创建页面! div比表重量轻
<div id='header' style='height:230px'>
</div>

<div id='body'></div>

<div id='footer' style='height:230px'>
</div>

谢谢 !

大佬总结

以上是大佬教程为你收集整理的css – html页面中的自定义页眉和页脚全部内容,希望文章能够帮你解决css – html页面中的自定义页眉和页脚所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。