I tried implementing a media query to "lock" the orientation on my mobile site, but unfortunately, my background image isn't displaying at all.
After adding the media query, I included my stylesheet using the link:
CSS
body {
padding:0;
margin:0;
font-family:Open-sans;
background-repeat: no-repeat;
background-image:url('paintingOg.gif');
background-color:grey;
background-size:100%;
}
@media (orientation: portrait) {
body {
transform:rotate(-90deg);
background-image:url('paintingOg.gif');
}
}
HTML
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="Lmob.css">
<script src="//code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.js"></script>
</head>
<body style="background-image:url('images/paintingOg.gif');">
<h1 id="orientation">orientationchange Not Supported on this Device. </h1>
<script>
$( window ).on( "orientationchange", function( event ) {
$( "#orientation" ).text( "This device is in " + event.orientation + " mode!" );
});
// You can also manually force this event to fire.
$( window ).orientationchange();
</script>