javascript - 清除正常 div 和固定 div 之间的边距

标签 javascript jquery html css laravel

我必须div 一个是固定的,它是所有页面的标题 以太是内容 这是我的代码

<style>
#print-head {
    display: none;
}
@media print {

    #print-head {
        display: block;
        position: fixed;
        top: 0pt;
        left:0pt;
        right: 0pt;
        text-align: center;
    }
}
</style>
<div id='print-head'>
    page header herer for all page
</div>
<div id='content'>
    content here coming from foreach loop
</div>

我的问题是 div 内容在第一页有很多行打印预览一切正常 标题内容看起来像这样 enter image description here

但在下一页中,内容将像这样与标题堆叠在一起 enter image description here

我需要一个代码来使内容 div 总是从顶部获得边距,而不仅仅是在第一页 我如何清除:每页中第一个 div 和第二个 div 之间的边距非常感谢

最佳答案

尝试

    #print-head {
    position: absolute;
    top: 0px;
    left:0px;
    width: 100%;
    text-align: center;
    padding: 20px 0;
}

关于javascript - 清除正常 div 和固定 div 之间的边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48526837/

相关文章:

javascript - 使用 jquery/javascript 合并字符串中的值

javascript - 是否可以使用 Javascript 检测所有版本的 IE?如何?

javascript - != null 和 !== null 有什么区别?

javascript - 数据类型为 'json' 的 jQuery ajax 方法错误地解析了 json 数据

PHP 在本地抓取和存储输出

html - 元素结束标记中的属性?

html - 为什么我的图像背景在 float : left? 上消失

javascript - 如何在 Javascript 中求正态分布?

javascript - 如何创建表示包含业务对象及其图形表示(jquery DOM 元素)的 Car 对象的 JS 对象

javascript - 如何使用 javascript 读取包含数组数据的本地 json 文件?