Fangming Du
Fangming Du

Reputation: 43

Use CSS Detect Page Orientation in Printing

I want to use CSS style to detect the page orientation in printing and then apply different styles when user choose different orientations (landscape or portrait).

@media print{ /*portrait*/  /*landscape*/}

Is there any way to do that?

Thanks

Upvotes: 3

Views: 4160

Answers (1)

eritbh
eritbh

Reputation: 796

Use the orientation: ... media selector. Here's an example:

@media print and (orientation: portrait) {
    /* Your code for portrait orientation */
}
@media print and (orientation: landscape) {
    /* Your code for landscape orientation */
}

Upvotes: 9

Related Questions