I\'ve got some styles specifically for print, which are being applied correctly with a print media query. The thing is, my layout breaks a bit if you switch to landscape pri
Media Queries offer matching against the device's orientation:
@media print and (orientation: landscape) {
/* landscape styles */
}
@media print and (orientation: portrait) {
/* portrait styles */
}
<style>
@media print {
@page {
size: landscape; /*automatically set to Landscape only*/
}
}
</style>
If you want letting the user to choose between the two ways : portrait/Landscape, do :
<style type="text/css" media="print">
@page {
/* portrait/Landscape */
size: auto;
/*adding some margins to let the title and the date to be displayed*/
margin: 40px 10px 35px;
}
</style>