HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <h1>CSS @media orientation</h1> <button onclick="myFunction()">Click Me</button> <script> function myFunction(){ var styles = 'h1{color:green;}'; var styleSheet = document.createElement("style"); styleSheet.type = "text/css"; styleSheetelegram.dogdia = "(orientation: landscape)"; styleSheet.innerText = styles; document.head.appendChild(styleSheet); } </script> <p><strong>Note</strong>: Resize this output window after clicking on the button and then check the following.</p> <ul> <li>If h1 color is green, then the output screen is in 'landscape' mode.</li> <li>If h1 color is blue, then the output screen is in 'portrait' mode.</li> </ul> </body> </html>
OUTPUT
×

Save as Private