Ensure there is a visible separation between standard div elements and fixed div elements

I have two divs - one is fixed as the header for all pages, and the other is for content. Here is my code:

<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 here for all pages.
</div>
<div id='content'>
    Content here coming from a foreach loop.
</div>

My problem is that the content in the div gets many lines in the print preview. On the first page, everything looks correct with the header and content displayed properly. However, on subsequent pages, the content overlaps with the header.

I need a way to ensure that the content div always has a margin from the top on every page, not just the first. How can I clear the margin between the first div and the second div on each page? Thank you.

Answer №1

Experiment with the following CSS code:

#main-container {
    position: relative;
    top: 50px;
    left:20px;
    width: 80%;
    text-align: center;
    padding: 30px 0;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips on modifiying CSS class created through JavaScript

I am making use of the visjs library and it is functioning well. However, I am facing an issue with changing the CSS class generated by this library (vis.js). The div elements are created dynamically by the JavaScript within the library itself. Can anyon ...

Triggering an event upon selecting a dropdown option

I'm currently working on a form that includes a dropdown menu. My goal is to display specific keywords for each trip when selected from the menu (preferably below the input field, as shown in the code snippet below). .show has been set to display:non ...

Manipulate data within multidimensional array by adding or requesting values

I have created a multidimensional array in the following way: var languageArray = {}; $('#language li a img').each(function(index) { var helperArray = []; helperArray.push(langi); helperArray.push(getnumber); languageArray.push(h ...

Dealing with the prompt "Are you certain you wish to leave this page?" when closing the page

When using my web application, a JavaScript message pops up asking 'Are you sure you want to navigate away from this page?' when attempting to open a new page. I am aware that I can handle this message with the Selenium.getAlert() method (or some ...

What are the most effective ways to manage state in form components using React?

As I delve into the realm of best practices for managing state in React components, I find myself grappling with different approaches. Initially, I crafted a form by creating a TextField component structured like this: var TextField = React.createClass({ ...

How can a form be submitted in Extjs without using ajax?

Hello there! I'm attempting to submit an extjs form without using ajax and display the result on the next page. Below is my code: Ext.define('test.from', { extend: 'Ext.form.Panel', alias: 'widget.test.form', ...

Is it possible to utilize Class objects within Google Apps Script Libraries?

Recently, I've been working on a JavaScript class that looks like this: class MyObject { constructor(arg1, arg2, arg3) { this.field1 = arg1; this.field2 = arg2; this.field3 = arg3; } myMethod(param1, param2) { return param + par ...

Are you able to choose the nth element within a Bootstrap column class in order to generate columns of varying sizes?

Is it possible to access the nth element of a column in Bootstrap v4.6 to change its size? I am looking to have 2 cards with unequal columns on the top and 2 cards with unequal columns on the bottom. <!doctype html> <html lang="en"> & ...

Encountering Issues with Deploying Angular/Express Application on Heroku: Frontend Unable to Access API Endpoint

During the development phase, everything runs smoothly with localhost:4200 for the front-end and localhost:8080 for the back-end. After deployment, the front-end is displayed without any issues. However, there is a problem with fetching data from the API ...

Efficient Management of Passed Variables in res.render() Using Node.js and Express

One of the routes in my app renders an HTML file using EJS, passing a variable along with it. myFunc(username).then(user=>{ res.render('normalHTML.ejs') }).catch(err => { res.render('error.ejs', {overwrite: er ...

The function Uri.EscapeDataString() helpfully changes the character "/" to %2F

I'm currently working on converting strings to URI format so that I can use them in URLs to display images on my webpage. My project is built using ASP.NET Core. So far, I've tried both System.Web.HttpUtility.UrlEncode() and Uri.EscapeDataString ...

API Services from the Environmental Authority

I am looking to develop a user-friendly web tool to request Environment Agency (EA) data through their API. You can find their guidelines here: If possible, I would prefer to use jquery for this project. My main query is: Does the provided link contain s ...

Navigating array usage in Selenium IDE

I am trying to extract emails from a webpage using Selenium for future testing. I need to compare these emails with ones displayed in a selection later on. I attempted to read the emails within a while-loop but struggled with handling arrays in IDE. Unfor ...

How can I use jQuery to hide each div of the same class individually when a user clicks on each div to close

I am working on a project where I have multiple notification boxes represented by divs with the same class. These boxes are set to fade in one after the other using jQuery. Each box also contains a 'close_box' div that acts as a button to close/h ...

The maximum size for MongoDB documents is restricted to 16 megabytes

When referring to Document, is it talking about the complete document collection or the individual documents within the collection? A similar question was posed on Stack Overflow: Mongodb collection maximum size limit? However, I am having trouble graspi ...

concentrate on the input box

Once I click on the CPM, my goal is to automatically place the cursor in the centralized field of this page: . Despite my attempts to use different code snippets in the console, I have not been successful. I experimented with document.getElementById("se ...

Build React Native for Android Instant Apps

After working as a Native Android Developer, I have recently joined a team that is developing an app using React-Native. My current task involves refactoring a previous app that I built using React-Native. The app I previously worked on supported Instant ...

What is the best way to align my two buttons in the center?

I'm having trouble aligning my two buttons to the center. Additionally, I'm not sure how to remove the gray color from inside the buttons. Here is the code: index.html <!DOCTYPE html> <html> <head> <met ...

What is the best method for targeting the clicked element using its class name?

I have a scenario where there are multiple elements with the same class name, but I am only interested in changing the class of the element that is clicked. var icon = $('.opener i'); // Need to target the class of the clicked element Functi ...

Create a custom div class specifically designed for an image button

Apologies if my title is a bit misleading, I struggled to find the right phrasing. Currently, I have images linked to various social networks using href. For instance, clicking on the facebook icon directs to my Facebook page. The layout looks like this: ...