CSS style designed for control of print design

Source: Internet
Author: User

Source: http://ourjs.com/detail/54d1ef3e232227083e000026

Most web designers are not familiar with print control, and they tend to be more obsessed with pixels than printers . In the real world, many people rely on Web pages for reference: In this digital age, in a number of special occasions, many people hold the paper in their hands . Web developers can take steps to compensate for the gap between the printer and the LCD screen.

Style for printer instead of screen design
1 /*  */2{3  4  5 }

You can also use a separate CSS file, set Link's media= "Print" property to specify that this style is dedicated to printing

<link type= "Text/css" rel= "stylesheet" href= "Css/print.css" media= "print" >

It is not necessary to reshape the entire CSS for your site, as a whole, by printing to inherit the default sample; In order to save toner when printing, most browsers will automatically invert the color. In order to achieve the best results, the color changes should be obvious:

1 /*  Black */ 2  {3   body {4      color: #000;  5      background: #fff;  6    }7}

We're not creating the entire page, just to show a well-designed, readable website:

1 /*Remove background image, save ink*/2 3 H1{4 Color:#fff;5 background:URL (banner.jpg);6}7 8 @media Print{9 H1 {Ten Color:#000; One background:None; A} -  - nav, aside{ the Display:None; -} - }

To make the printer more efficient, you should only show the body content, remove the header and footer navigation bar

1 @media Print{2 H1 {3 Color:#000;4 background:None;5}6 7 nav, aside{8 Display:None;9}Ten  One body, article{ A width:100%; - margin:0; - padding:0; the} -  - @page{ - margin:2cm; +} - }
Processing of links

Hyperlinks are not visible on the printer and should be extended

1 /*add a full address with */2 @media Print{3 article a {4 Font-weight:Bolder;5 text-decoration:None;6}7 8 article A[href^=http]:after{9 content:"<" attr (HREF) ">";Ten} One }

The display might look like this:

Control Print Setup Options

The @page rule allows you to specify various aspects of the page. For example, you will specify the dimensions of the page. Margins, header footers, and so on are all important. [Many browsers are supported]

@PAGE Regular paper size settings

With this CSS you can set the paper size, 5.5 inches wide and 8.5 inches high.

{  size: 5.5in 8.5in;}

You can also control the paper size by alias, such as "A4" or "legal."

{  size: A4;}
You can also control the direction of printing, Portrait: Portrait print, Landscape: landscape
{  size: A4 landscape;}
Page Model the page models

In a paged media format model, documents are transferred to one or more page boxes. The page box is mapped to a rectangular plane. This is roughly similar to the CSS box model. (Note * Fewer browsers supported)

{ width: 50em;}
Page margin model Page-margin boxes before further discussion, we should understand the box model of the page, because its behavior is somewhat different from how it works on the screen. The page model defines the page area and then divides the 16-week edge box. You can control the size of the page area and the margin between the edge of the page area and the end of the page itself.

Left and right margins

{  margin-left: 30cm;}  {  margin-left: 4cm;}

The following CSS will show the title on the bottom left, the page counter in the lower right corner, and a chapter title in the upper right corner.

1 @page: Right{2 @bottom-left {3 margin:10pt 0 30pt 0;4 Border-top:. 25pt Solid #666;5 content:"Our Cats";6 font-size:9pt;7 Color:#333;8}9 Ten @bottom-right{ One margin:10pt 0 30pt 0; A Border-top:. 25pt Solid #666; - content:Counter (page); - font-size:9pt; the} -  - @top-right{ - content:string (doctitle); + margin:30pt 0 10pt 0; - font-size:9pt; + Color:#333; A} at }

The display results are as follows:

Note * This article is organized from: Tips and Tricks for print Style Sheets and designing for print with CSS and CSS3 page specification

CSS style designed for control of print design

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.