javascript - Jquery animated div margins appear to change depending on window resize -


problem: have animated div 2d rendering of cube, each face being new page. however, whenever page resized (say on mobile device or tablet or giant desktop) left , right sides of square change position in relation edges of window, , different every turn of "cube". follow link below, resize screen smaller , try clicking on menu items see mean. top , bottom remain constant, left , right moving off of true center.

question: how "cube" face remain centered no matter menu item clicked? thank help, time , patience!

website: http://studiopowell.net/tp.html relevant code below:

        <style>       .face {       position: absolute;       height: 100%;       width: 97%;       padding: 20px;       margin: 0 auto;       background-color:rgba(20,20,20,.5);       border: solid 1px #ccc;       pointer-events: none;     }       #cube {       position: relative;       margin: 0 auto;       height: 70%;       width: 80%;       -webkit-transform-style: preserve-3d;       -webkit-transition: 2s ease;       transform-style: preserve-3d;       transition: 2s ease;       pointer-events: none;     }      #cube .one {       -webkit-transform: rotatex(90deg) translatez(200px);       transform: rotatex(90deg) translatez(200px);     }      #cube .two {       -webkit-transform: translatez(200px);       transform: translatez(200px);     }      #cube .three {       -webkit-transform: rotatey(90deg) translatez(200px);       transform: rotatey(90deg) translatez(200px);     }      #cube .four {       -webkit-transform: rotatey(180deg) translatez(200px);       transform: rotatey(180deg) translatez(200px);     }     #cube .five {       -webkit-transform: rotatey(-90deg) translatez(200px);       transform: rotatey(-90deg) translatez(200px);     }      #cube .six {       -webkit-transform: rotatex(-90deg) translatez(200px) rotate(180deg);       transform: rotatex(-90deg) translatez(200px) rotate(180deg);     }        canvas {         position: absolute;         top: 0;         left: 0;         max-height: 100%;         max-width:100%;         min-height: 100%;         min-width:100%;     }         </style>      <canvas id="c"></canvas>     <div class="menu"><div id="aboutlink">about</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div id="futurelink">future</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div id="pastlink">past</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div id="contactlink">contact</div></div>     <div class="text">transversal</br>project</div>     <div id="cube">     <div class="face one"></div>     <div class="face two"></div>     <div class="face three"></div>     <div class="face four"></div>     <div class="face five"></div>     <div class="face six"></div>       </div>        <script src="http//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>     <script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/1.16.1/tweenmax.min.js"></script>     <script src="http://dat-gui.googlecode.com/git/build/dat.gui.min.js"></script>     <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>     <script>     $(document).ready(function(){      $("#aboutlink").click(function(){        calcrotation(0);     });     $("#futurelink").click(function(){       calcrotation(90);     });     $("#pastlink").click(function(){        calcrotation(180);     });     $("#contactlink").click(function(){     calcrotation(270);     });     function calcrotation(rot){        $("#cube").css("transform", "rotatey(-" + rot + "deg)");     }     });     </script> 


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -