3
Answers

CSS Print StyleSheet Not Working on Webforms

Hold On

Hold On

7y
247
1
Can someone help me how to use correctly the css for media print? I'm very novice when it comes to html and css, hence, all the styles that I use is inline. I tried to follow what I found on google on how to use the media print but no luck. Below is a snippet of my css media print where it doesn't work.
  1. <style>  
  2.         @media print {  
  3.             .imageLogo {  
  4.                 margin-top: 5px;  
  5.             }  
  6.   
  7.             .fontfamily {  
  8.                 font-family: 'Phetsarath OT';  
  9.                 text-align: center;  
  10.                 font-weight: bold;  
  11.             }  
  12.   
  13.             .regularfont {  
  14.                 text-align: center;  
  15.                 font-weight: bold;  
  16.             }  
  17.   
  18.             .sched {  
  19.                 text-align: center;  
  20.                 font-weight: bolder;  
  21.                 font-family: 'Phetsarath OT','Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;  
  22.                 font-size: 35px;  
  23.             }  
  24.   
  25.             .leftSide {  
  26.                 width: 200px;  
  27.             }  
  28.   
  29.             .next-to-left {  
  30.                 width: 300px;  
  31.             }  
  32.   
  33.             .grid {  
  34.                 margin-left: 200px;  
  35.             }  
  36.   
  37.             .gridview td {  
  38.                 width: 300px;  
  39.                 text-align: center;  
  40.             }  
  41.         }  
  42.     </style>  
 Thanks in advance for any help.
Answers (3)
0
Manas Mohapatra

Manas Mohapatra

NA 29.3k 3.3m 7y
 
Make sure that you have correct css class names.
Make sure CSS are applied properly in your web form.
 
Lastly follow below links that may help you: 
 
http://www.c-sharpcorner.com/UploadFile/skumaar_mca/media-css-for-print-the-web-page-in-customized-format/
 
 https://weblogs.asp.net/dwahlin/getting-started-with-css-media-queries
 
Note: Try in some latest browsers. 
Accepted
0
Hold On

Hold On

NA 390 13.6k 7y
Hello again Manas, it's working now! I am using a panel that's why it is not working. When I transfer the link inside the panel, it worked! Thanks for your help.
0
Hold On

Hold On

NA 390 13.6k 7y
Hello Manas thanks for the prompt reply. As usual I did follow point per point, instruction per instruction but what I don't understand that when I'm going to use media="print" it doesn't work. On the other hand, media="screen" works very well. We cannot say that the class name is not correct because its working using media="screen".