Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can remove border from table while printing using css @media print

Hello I try to remove border from my table when the user click button print (window.print) using css but it stay always in printed page

this is my css code :

    @media print{

    body * {visibility: hidden;


    }

    table {
        border:solid; white !important;
        border-width:1px 0 0 1px !important;
        border-bottom-style: none;
    }
    th, td{
        border:solid; white !important;
        border-width:0 1px 1px 0 !important;
        border-bottom-style: none;
    }
}

this css gave me this result :

enter image description here

The bottom border of table stay showing How do I can remove it Thank u

like image 986
e2rabi Avatar asked Mar 10 '23 05:03

e2rabi


1 Answers

You could use in your CSS3 @media Rule:

border-bottom: none;

or

border: solid white !important;

Using border-bottom: none; could effect the layout of you table when printing (depending if you are using box-sizing with default value or not).

Below an example:


<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8" />
    <style>
        table {
            /* just an example */
            border: solid red;
            border-width: 1px 0 0 1px !important;
            border-bottom-style: none;
        }

        @media print {

            table {
                border: solid white !important;
                border-width: 1px 0 0 1px !important;
                border-bottom-style: none;
            }

            th, td {
                border: solid white !important;
                border-width: 0 1px 1px 0 !important;
                border-bottom-style: none;
            }
        }
    </style>
</head>
<body>
    <table style="width:100%">
        <tr>
            <th>Firstname</th>
            <th>Lastname</th>
            <th>Age</th>
        </tr>
        <tr>
            <td>Jill</td>
            <td>Smith</td>
            <td>50</td>
        </tr>
        <tr>
            <td>Eve</td>
            <td>Jackson</td>
            <td>94</td>
        </tr>
    </table>
</body>
</html>
like image 140
GibboK Avatar answered Apr 24 '23 22:04

GibboK