在打印模式下对齐HTML元素

时间:2014-07-16 14:19:28

标签: html css printing

我有一个html <footer>元素,我试图让它像word文档中的页脚一样。换句话说,页脚需要位于页面底部。有没有办法使用CSS @media print将页脚移动到该特定页面的底部?此外,页脚必须移动的空间可能因页面而异。有没有办法限制该元素移动距离超过一定距离?

我的代码

footer p {
    color: green;
    text-align: center;
    font-size: 11px;
    display: none;
}

footer div {
    color: green;
    border: 1px solid green;
    display: none;
}

@media print {
    footer p {
        display: block !important;
        position: fixed;
        bottom: 0;
    }
    footer div {
        display: block !important;
        position: fixed;
        bottom: 0;
    }
}

div在任何页面上都不可见,而p仅在第一页上可见。

0 个答案:

没有答案