Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The script also <a href="https://stackoverflow.com/questions/986937/how-can-i-get-the-browsers-scrollbar-sizes/986977#986977">calculate the scrollbar size</a> if needed. You will need a block (<code>div</code>, <code>span</code>, etc...) with the <em>wrapper</em> id.</p> <p>This is a <strong>cross-browser</strong> script, it supports all the modern browsers.</p> <p>I hope you like it. Feel free to use!</p> <pre><code>// DONT FORGET TO ADD THIS TO YOUR WRAPPER'S CSS BLOCK // THIS WILL KEEP YOUR SITE CENTERED // IF YOU USE margin-left:auto; margin-right:auto; // transform-origin: 50% 0%; // -ms-transform-origin: 50% 0%; // -moz-transform-origin: 50% 0%; // -webkit-transform-origin: 50% 0%; // -o-transform-origin: 50% 0%; function FitToScreen(FitType) { var Wrapper = document.getElementById('wrapper'); var ScreenWidth = window.innerWidth; var ScreenHeight = window.innerHeight; var WrapperWidth = Wrapper.offsetWidth; var WrapperHeight = Wrapper.offsetHeight + 200; var WidthRatio = parseFloat(ScreenWidth/WrapperWidth); var HeightRatio = parseFloat(ScreenHeight/WrapperHeight); var ScaleRatio = 1.0; if (FitType == 'width') { ScaleRatio = WidthRatio; if(ScaleRatio * WrapperHeight &gt; ScreenHeight) { ScaleRatio = parseFloat(ScreenWidth/(WrapperWidth + GetScrollBarWidth () -1)); } } else if (FitType == 'height') { ScaleRatio = HeightRatio; if(ScaleRatio * WrapperWidth &gt; ScreenWidth) { ScaleRatio = parseFloat(ScreenHeight/(WrapperHeight + GetScrollBarWidth () -1)); } } var ScaleText = 'scale(' + ScaleRatio.toString().replace(',','.') + ')'; //Chrome and Safari Wrapper.style.webkitTransform = ScaleText; //Firefox Wrapper.style.MozTransform = ScaleText; //Internet Explorer Wrapper.style.msTransform = ScaleText; //Opera Wrapper.style.OTransform = ScaleText; //Standard Wrapper.style.transform = ScaleText; } function GetScrollBarWidth () { var inner = document.createElement('p'); inner.style.width = '100%'; inner.style.height = '200px'; var outer = document.createElement('div'); outer.style.position = 'absolute'; outer.style.top = '0px'; outer.style.left = '0px'; outer.style.visibility = 'hidden'; outer.style.width = '200px'; outer.style.height = '150px'; outer.style.overflow = 'hidden'; outer.appendChild (inner); document.body.appendChild (outer); var w1 = inner.offsetWidth; outer.style.overflow = 'scroll'; var w2 = inner.offsetWidth; if (w1 == w2) w2 = outer.clientWidth; document.body.removeChild (outer); return (w1 - w2); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload