CSS:@media打印没有外部css文件? [英] CSS: @media print without external css file?

查看:245
本文介绍了CSS:@media打印没有外部css文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在css下以特定方式打印html页面。但是所有的@media打印示例似乎有一个外部.css文件我想能够做到没有外部文件,这意味着没有链接rel标签:

I want to print a html page in a specific way under css. But all the @media print examples seem to have an external .css file I want to be able to do it without an external file which means there will be no link rel tag:

 <LINK REL="stylesheet" MEDIA="print...

我该如何做?

推荐答案

我建议使用外部样式表,如果您真的想要与HTML相同的网页,则示例如下:

I would suggest using an external stylesheet but you can how ever do this on the same page as your HTML if you really want to, an example of this would be like so,

HTML / CSS

<!DOCTYPE html>
<html>
    <head>
         <style>
              @media print {

                   /* changes the display property to none on all 
                      p elements when printed */
                   p { display: none}
              }
         </style>
    </head>
    <body>
         <p>I'm here when the page isn't printed</p>
    </body>
</html>

这篇关于CSS:@media打印没有外部css文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆