I have a stylesheet t开发者_如何转开发hat looks like this:
body{
 background: #333;
}
...
@media print {
 body{
  background: #fff;
  color: #000;
  font-size: 10pt
 }
 ...
}
the print styles work ok and are applied when you go in print preview mode in your browser.
However I have a "print" button on the site, which when pressed, outputs the current page in print mode (same page, but containing only the relevent info, no menus, sidebar etc)
How can I enable the print styles in this page? If I include the stylesheet it will style it as the other pages...
- Create a print.css without the - @media printpart
- Include it once in the header like so: - <link rel="stylesheet" type="text/css" media="print" href="print.css">
- Include it as regular CSS when you want to load the page in print mode. 
 Put e.g. something like this in the header:
<?php
if ($_GET['view']=='print') {
 echo '<link rel="stylesheet" type="text/css" href="print.css">';
}
?>That way it'll be included when you load a URL like some_page.php?view=print as well as when you go into the browsers print preview window.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论