Home > Web Front-end > CSS Tutorial > CSS styles you need to pay attention to when printing on the web

CSS styles you need to pay attention to when printing on the web

一个新手
Release: 2017-09-14 11:11:09
Original
1993 people have browsed it

Today I wrote a function that prints on the front end, and encountered a very pitiful problem. The set background color did not work when printing:
The css style that did not work:

.p_class2_1{       
color:white;       
float:left;       
background: #808080!important;  
width:80%;  
}    
.p_class3_1{     
color:white;     
float:left;     
background: #808080!important;  
width:100%;
}       
.p_class5_1{     
color:white;    
background: #808080!important;  
width:100%;
}
Copy after login

Result Nothing worked,
CSS styles you need to pay attention to when printing on the web

was later solved through various methods:
The following is the solution code:

.p_class2_1{       
color:white;       
float:left;      
 background: #808080!important;  
       filter:progid:DXImageTransform.Microsoft.gradient(startColorStr='#808080',EndColorStr='#808080');  
       width:80%;
       }
       .p_class3_1{     
       color:white;     
       float:left;    
       background: #808080!important;  
     filter:progid:DXImageTransform.Microsoft.gradient(startColorStr='#808080',EndColorStr='#808080');  
     width:100%;}
     .p_class5_1{     
     color:white;     
     background: #808080!important;  
     filter:progid:DXImageTransform.Microsoft.gradient(startColorStr='#808080',EndColorStr='#808080');  
     width:100%;}   

 @media print {  
        .p_class2_1 {-webkit-print-color-adjust: exact;}  
        .p_class3_1 {-webkit-print-color-adjust: exact;} 
        .p_class5_1 {-webkit-print-color-adjust: exact;} 
    }
Copy after login

The results are as follows:
CSS styles you need to pay attention to when printing on the web

I found the background color that was not displayed before, but it is now displayed!
The most important code is@media print { <br> .p_class2_1 {-webkit-print-color-adjust: exact;} <br> .p_class3_1 {-webkit-print-color-adjust: exact;} <br> .p_class5_1 {-webkit-print-color-adjust: exact;} <br> } @media print is to display the background color when printing. It is not displayed by default!

The above is the detailed content of CSS styles you need to pay attention to when printing on the web. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template