After creating a CSS style sheet that can print an HTML page in landscape mode using the @media rule shown below:
@media print{
@page {size: landscape;}
}
I realized that I don't want every HTML page that loads this style sheet to automatically be printed in landscape mode. It would be more ideal if I could specify a particular class to trigger this layout.
Generating the HTML dynamically, I considered attaching a separate landscape.css file to the header whenever needed. However, I was hoping for a cleaner solution involving classes.
In my attempt to find an alternative, I experimented with the following code:
@page rotated {
size: landscape;
}
@media print{
.rotate {
page: rotated;
}
}
Unfortunately, this approach seems to only work on webkit based browsers, as the @page size: landscape setting does not function properly in Firefox or ie10.