How can we prevent extra data from showing up in print when using CSS media for printing?

While working on a Laravel project, I implemented CSS media print in one section. Although it works well, the Chrome Print Dialog displays additional data as shown in the image I marked below. I want to prevent this data from showing up when printing. Can anyone advise me on how to avoid this?

This is the HTML code:

<div class="row">
   <h3 style="margin-right: 14px;">مشخصات شاگرد</h3>
   <div class="col-md-4" style="padding-left: 0px;" id="student_info">
      <div class="list-group">
         <a href="" class="list-group-item disabled  student_details">نام</a>
         <a href="" class="list-group-item student_details">تخلص</a>
         <a href="" class="list-group-item disabled student_details">نام پدر</a>
         <a href="" class="list-group-item student_details">جنسیت</a>
         <a href="" class="list-group-item disabled student_details">سن</a>
         <a href="" class="list-group-item student_details">تلیفون</a>
         <a href="" class="list-group-item student_details disabled">آدرس</a>
         <a href="" class="list-group-item student_details">ایمیل</a>
         <a href="" class="list-group-item student_details disabled">حالت مدنی</a>
         <a href="" class="list-group-item student_details">نمبر تذکره</a>
      </div>
   </div>
   <div class="col-md-8" style="padding-right: 0px;" id="student_info_date">
      <div class="list-group">
         <a href="" class="list-group-item student_details disabled"> {{ $student->first_name }} </a>
         <a href="" class="list-group-item student_details">{{ $student->last_name }}</a>
         <a href="" class="list-group-item student_details disabled"> {{ $student->father_name }} </a>
         <a href="" class="list-group-item student_details">{{ $student->gender }}</a>
         <a href="" class="list-group-item student_details disabled"> {{ $student->age }} </a>
         <a href="" class="list-group-item student_details">{{ $student->phone }}</a>
         <a href="" class="list-group-item student_details disabled"> {{ $student->address }} </a>
         <a href="" class="list-group-item student_details"> {{ $student->email_address }} </a>
         <a href="" class="list-group-item student_details disabled"> {{ $student->marital_status }} </a>
         <a href="" class="list-group-item student_details"> {{ $student->ssn_number }} </a>
      </div>
   </div>
</div>

This is my script code:

<script>
   $(document).ready(function () {
      $('#print').click(function () {
          window.print()
      })
   })
</script>

This is the style for printing:

<style>
    @media print  {
        body * {
            visibility: visible !important;
        }
        @page  {

            margin: 0;
        }
        #print,.fixed-navbar{
            display: none;
        }
        #student{
            margin-top: -70px;
        }
        #student_info
        {
            width: 15%;
        }
        #student_info_date,
        #student_info_date{
            margin-right:15% ;
            margin-top: -535px;
            width: 30%;
        }
        #student_family{
            margin-right: 41%;
            margin-top: -797px;
        }
        #student_family_info{
            width: 25%;
        }
        #student_family_info_data{
            width: 45%;
            margin-right: 25%;
            margin-top: -546px;


        }

    }
    a.student_details{
        max-height:100px;
        min-height: 50px;
    }
    a.student_class_details{
        min-height: 90px;
    }
    a.student_class_score_details{
        min-height: 90px;
        padding:28%;
    }

</style>

Answer №1

Replace all instances of <a> with <span>.

<div class="row">
   <h3 style="margin-right: 14px;">Student Details</h3>
   <div class="col-md-4" style="padding-left: 0px;" id="student_info">
      <div class="list-group">
         <span href="" class="list-group-item disabled student_details">First Name</span>
         <span href="" class="list-group-item student_details">Last Name</span>
         <span href="" class="list-group-item disabled student_details">Father's Name</span>
         <span href="" class="list-group-item student_details">Gender</span>
         <span href="" class="list-group-item disabled student_details">Age</span>
         <span href="" class="list-group-item student_details">Phone Number</span>
         <span href="" class="list-group-item student_details disabled">Address</span>
         <span href="" class="list-group-item student_details">Email Address</span>
         <span href="" class="list-group-item student_details disabled">Marital Status</span>
         <span href="" class="list-group-item student_details">SSN Number</span>
      </div>
   </div>
   <div class="col-md-8" style="padding-right: 0px;" id="student_info_date">
      <div class="list-group">
         <span href="" class="list-group-item student_details disabled"> {{ $student->first_name }} </span>
         <span href="" class="list-group-item student_details">{{ $student->last_name }}</span>
         <span href="" class="list-group-item student_details disabled"> {{ $student->father_name }} </span>
         <span href="" class="list-group-item student_details">{{ $student->gender }}</span>
         <span href="" class="list-group-item student_details disabled"> {{ $student->age }} </span>
         <span href="" class="list-group-item student_details">{{ $student->phone }}</span>
         <span href="" class="list-group-item student_details disabled"> {{ $student->address }} </span>
         <span href="" class="list-group-item student_details"> {{ $student->email_address }} </span>
         <span href="" class="list-group-item student_details disabled"> {{ $student->marital_status }} </span>
         <span href="" class="list-group-item student_details"> {{ $student->ssn_number }} </span>
      </div>
   </div>
</div>

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

Dynamic content editing with EJS

Currently, I am using Express and mongoDB for the back end, and EJS for the front end. The code snippet below shows that I have a content editable element, and my goal is to capture the value after clicking the modify button. At the moment, the value com ...

javascript for transforming date format

My textfield is set to be a date field with a jQuery datepicker(). The dateFormat() is dd-mm-yy, which works perfectly. However, MySQL requires dates to be in yyyy-mm-dd format. I am wondering if I can convert the date format using PHP or JavaScript before ...

How can you make divs adapt to screen resizing in a similar way to images?

In my REACT project, I am faced with the challenge of positioning three divs next to each other, with a small margin between them, and ensuring they are horizontally centered on the screen. As the screen width decreases, I need the right-most div to move ...

What could be causing my code to generate an error?

I'm encountering an error in module.js:339 where it throws an 'err' and I'm struggling to identify the exact cause or line of code that needs fixing. Any guidance on where to look would be greatly appreciated, as I seem to be searching ...

Closing a Javascript-created popup using server-side code

I'm encountering an issue with closing a modal that I've created in JavaScript. The goal is to display a loading spinner while data is being fetched, and then hide it once the background process is complete. Everything functions correctly until t ...

Problem with Raphael Sketch and Request to Ajax

Utilizing Raphael.js and jQuery Ajax, I am attempting to display some dots (circles) on the map in this [Demo][1]. I have a PHP file called econo.php which looks like this: <?PHP include 'conconfig.php'; $con = new mysqli(DB_HOST,DB_USER,DB_P ...

There seems to be an issue with connecting to the local server at https://localhost:3000/socket.io/ while using a

I am currently working on a Node.js project where I have a client.js for client-side code, and a server.js on a remote server using sockets to communicate over port 3000 In addition, Apache is running on port 80, with a ProxyPass configuration in place to ...

Tips for incorporating "are you sure you want to delete" into Reactjs

I am currently working with Reactjs and Nextjs. I have a list of blogs and the functionality to delete any blog. However, I would like to display a confirmation message before deleting each item that says "Are you sure you want to delete this item?" How ...

Bootstrap 4 menu toggle malfunctioning

After extensively searching for a solution to this issue on multiple threads in Stack Overflow, I am baffled as to why it is not working. The example below (taken from a thread on this topic) functions correctly in jsFiddler, but fails to work when served ...

Is there a way to view a list of URLs all at once in a single window?

Is there a way to open multiple URLs in a single tab? I have a list of URLs that I want to open and cache the contents without cluttering my browser with numerous tabs. ...

Is the "require" function absent in Firebase?

I'm encountering an issue while trying to execute an HTML file in the Firebase staging environment. I have included the Firebase npm package in my JavaScript code, but when it runs in the browser, I get an error stating "require is not defined". HTML ...

An error has occurred in the Next.js App: createContext function is not defined

While developing a Next.js application, I keep encountering the same error message TypeError: (0 , react__WEBPACK_IMPORTED_MODULE_0__.createContext) is not a function every time I try to run my app using npm run dev. This issue arises when attempting to co ...

Exploring the concept of utilizing named arguments within Express.js routing

I've searched extensively, but can't seem to find any information on this topic. My goal is to create requests like the following: url/list/message=hello?id=1234 Despite my efforts, I have not come across any resources on how to achieve this us ...

The hyperlinks lead to pages that are not related to the topic at

My goal was to make links interactive using JQUERY when they are clicked. After some research, I discovered a code snippet on stackoverflow that seemed to work well. However, when I clicked on the links, they would become bold or active as intended, but t ...

Unable to retrieve base64 data at the component level (Angular framework)

Currently, I am working on a GET API request to retrieve an image. The response returns with a status of 200 and the image data is in base64 format. However, I am facing an issue where I am unable to read the response within my component. Below is the code ...

Located just above the edge of the screen with absolute positioning

One of the features on my website is a small modal that smoothly slides in from the top of the page upon entering, and then slides back out again when clicked on. However, I am encountering an issue where I do not want the modal to completely disappear aft ...

Validation of forms in AngularJS/HTML5 that are nested within one another

Just starting out with AngularJS and experiencing issues with HTML5 nested form validation. I currently have 2 forms; mainFrm (parent form) and stateFrm (a child form). I am struggling to validate each form within its own scope. <form id="mainFrm" ng- ...

Tips for encoding a base64 string into formats such as PDF, doc, xls, and png using jQuery, JavaScript, and HTML5

Need help handling base64 strings received from the server to save files in multiple browsers (IE, FF, Chrome). If receiving a PDF base64 string, how can it be saved in the browser? Also, if receiving an Image or Doc base64 string, what is the process fo ...

Sending data from a React application to a Node.js server using Axios

Hello, I am facing an issue with an axios request to post data to a Node.js server. When trying to access this data on the server, it is showing as undefined. Below is the function for posting data: function Submit() { let params={ firstName: ...

What is the best way to utilize getInitialProps specifically during the building process of a NextJS site?

When I am developing a static site using NextJS, I need the getInitialProps method to run specifically during the build process and not when the client loads the page. During the build step, NextJS executes the getInitialProps method before generating the ...