Home  >  Article  >  Web Front-end  >  css 为要打印的页面设置css样式表的几种方法

css 为要打印的页面设置css样式表的几种方法

WBOY
WBOYOriginal
2016-06-01 09:53:151626browse

方法一:使用link引入外部样式表。

<code class="language-html"><link rel="stylesheet" href="css/style.css" media="print"></code>

media属性设置为print,表示该样式作用于打印。

 

二.import方式引入样式表。

<code class="language-css"><style type="text/css">
@import url("css/printstylesheet.css") print;
</style></code>

以上代码引入的样式可以用于打印样式。

 

三.页面样式和打印样式在同一个文件中

<code class="language-css">@media print{
h1{
color:black;
}
h2{
color: gray;
}
}
div{color:red}</code>

以上就是设置打印样式的三种方法。 

Statement:
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
Previous article:css 宽度 widthNext article:Bootstrap不支持IE的解决方法