javascript - How to rotate HTML5 page on mobile rotation -


hi i'm trying rotate html page on mobile have div take width , height of screen , inside div image when page re-sized image re-sized (in responsive way) css:

body, html {       height: 100%; }  body {  background-color: #1e4922; }  div#cont {   height: 100%; }  img#menu {     display: block;     margin-left: auto;     margin-right: auto;     height: 100%; } 

and html:

<!doctype html>  <html>  <head>     <title>card game</title>     <link rel="stylesheet" type="text/css" href="css/style.css"> </head> <body>          <div id="cont">         <img id="menu" src="static/images/2%20main%20menu.jpg"/>    </div> </body> </html> 

and result when re-size page image re-sized when open page in mobile need display in landscape view try this:

<link rel="stylesheet" type="text/css" media="screen , (max-device-width: 768px)" href="portrait.css" />  <link rel="stylesheet" type="text/css" media="screen , (min-device-width: 1024px)" href="landscape.css" /> 

like in link , landscape.css put this:

body, html {       height: 100%; }  body {  background-color: #1e4922; }  div#cont {   height: 100%; }  img#menu {     display: block;     margin-left: auto;     margin-right: auto;     height: 100%; } div#cont {      -webkit-transform: rotate(90deg);     -moz-transform: rotate(90deg);     -o-transform: rotate(90deg);     -ms-transform: rotate(90deg);     transform: rotate(90deg); } 

and in portrait.css

    body, html {       height: 100%; }  body {  background-color: #1e4922; }  div#cont {   height: 100%; }  img#menu {     display: block;     margin-left: auto;     margin-right: auto;     height: 100%; } 

form link not working , many thanks.

you can use javascript detecting device orientation

function callback(){   alert(window.orientation);   if(window.innerheight > window.innerwidth){     /* code */   } }  window.addeventlistener('orientationchange', callback, true); 

or css media queries

/* portrait */ @media screen , (orientation:portrait) {     /* code */ } /* landscape */ @media screen , (orientation:landscape) {     /*  code */ } 

or using html

<link rel="stylesheet" type="text/css" href="landscape.css" media="screen , (orientation: landscape)"> <link rel="stylesheet" type="text/css" href="portrait.css" media="screen , (orientation: portrait)"> 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -