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

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

WBOY
Release: 2016-06-01 09:53:15
Original
1694 people have browsed it

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

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

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

 

二.import方式引入样式表。

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

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

 

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

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

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template