欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
  首先我们来看看CSS媒体类型有哪些?
 
  screen(屏幕)
 
  print(打印)
 
  tv(电视)
 
  projection(投影仪)
 
  all(全部)
 
  当然还有其他的类型,但是我们主要就是介绍使用print来制作打印页面。
 
  我们下面来看CSS设置页面打印的具体内容
 
  有两种实现的方式
 
  第一种
 
  CSS代码
 
  <linkrel="stylesheet"type="text/css"href="sample_print.css"media="print">
 
  在这里经常使用<link>,仅在通过设置内部的“media=”print“”进行打印时才应用CSS。
 
  通过上述这种方式,需要编写两种类型的CSS,一个普通的Web页面和一个用于打印的Web页面。
 
  第二种
 
  我们来看下面的CSS代码
 
  @mediaprint{
 
  /*print的内容*/
 
  }
 
  这是由媒体类型实现的,通过这样做,可以在CSS的内部应用“@mediaprint”
 
  我们以第一种方式为例来看具体的示例
 
  代码如下
 
  HTML代码
 
  <!DOCTYPEhtml>
 
  <html>
 
  <head>
 
  <metacharset="utf-8">
 
  <title>CSS打印方法</title>
 
  <linkrel="stylesheet"type="text/css"href="sample_print.css"media="print">
 
  <linkrel="stylesheet"type="text/css"href="sample_screen.css"media="screen">
 
  </head>
 
  <body>
 
  <h1>Sample</h1>
 
  <p>如果是打印页可以看到文字</p>
 
  </body>
 
  </html>
 
  CSS代码
 
  sample_print.css
 
  p{
 
  color:#000000;
 
  }
 
  sample_screen.css
 
  p{
 
  color:#ffffff;
 
  }





本文转载自中文网

 

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/rumen/r56411.shtml