Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用HTML&;CSS在除第一页和最后一页之外的所有打印页上显示特定内容_Html_Css_Printing - Fatal编程技术网

使用HTML&;CSS在除第一页和最后一页之外的所有打印页上显示特定内容

使用HTML&;CSS在除第一页和最后一页之外的所有打印页上显示特定内容,html,css,printing,Html,Css,Printing,我试图控制HTML页面的打印方式,即在哪个页面上显示哪些内容。 内容足够长,可以打印出多个纸质页面 我需要一些内容只显示在第一页和最后一页上,其他内容显示在除第一页和最后一页外的每一页上 所以我有两个DIV元素,一个被归类为“content1”,应该只出现在第一页和最后一页,以及每一页的底部。 另一个被归类为“content2”,应该出现在所有页面上,在页面底部,除了第一页和最后一页 <div class="content1">appear only in the

我试图控制HTML页面的打印方式,即在哪个页面上显示哪些内容。 内容足够长,可以打印出多个纸质页面

我需要一些内容只显示在第一页和最后一页上,其他内容显示在除第一页和最后一页外的每一页上

所以我有两个DIV元素,一个被归类为“content1”,应该只出现在第一页和最后一页,以及每一页的底部。 另一个被归类为“content2”,应该出现在所有页面上,在页面底部,除了第一页和最后一页

<div class="content1">appear only in the first page and the last page, and at the bottom of each page</div>
<div class="content2">appear on all pages, on the bottom of the page, except the first and last page</div>
本应用于选择打印文档的第一页。 所以我试了一下:

@page :first {
        .content1{
            display: none;
        }

        .content2{
            display: inline-block;
        }
    }
但出于某种原因,我不在谷歌浏览器上为自己工作。 我找不到选择最后一页的方法

<div class="content1">appear only in the first page and the last page, and at the bottom of each page</div>
<div class="content2">appear on all pages, on the bottom of the page, except the first and last page</div>
这里有一个我到目前为止尝试过的JSFIDLE链接:


有什么方法可以实现我想要的吗?

在你的css中,你在
@page
之间没有空间:首先
谢谢,我把它编辑成一个jsfildle,在这里的帖子里。它仍然不起作用,@page规则只能包含页面属性和边距:所以现在我完全不知道如何实现我想要的