jquery - Resolution independent websites? (Or, "Scaling an entire website to fill the browser") -



jquery - Resolution independent websites? (Or, "Scaling an entire website to fill the browser") -

i'm working on project benefit filling whole screen -- it's 1 7000px-long page giant background filling whole length (probably chopped separate pieces , loaded in intelligent sequential fashion in final version), 5 or 6 different segments/areas/slides (basically, "content areas") scroll down.

at top navigation bar fills entire horizontal width of design. below it, on background, bunch of different elements, placed @ specific positions on background. placement on background critical each element specific section of page.

it seems me doing http://windyroad.org/2007/05/18/resolution-independent-web-design/ really useful. alas, that's 2007 , seems more proof-of-concept anything. plus seems bad thought resize 1000x7000px image php every time resizes browser window (or worse, 5 1000x1000 images!).

i've used jquery scripts scale background image fill entire browser, never ran across scales every element on page.

is there way dynamically scale entire website fit browser window?

i'm pretty sure know answer, figured i'd toss out there in case has idea.

many thanks!

the script calculate scrollbar size if needed. need block (div, span, etc...) wrapper id.

this cross-browser script, supports modern browsers.

i hope it. sense free use!

// dont forget add together wrapper's css block // maintain site centered // if utilize 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 > screenheight) { scaleratio = parsefloat(screenwidth/(wrapperwidth + getscrollbarwidth () -1)); } } else if (fittype == 'height') { scaleratio = heightratio; if(scaleratio * wrapperwidth > screenwidth) { scaleratio = parsefloat(screenheight/(wrapperheight + getscrollbarwidth () -1)); } } var scaletext = 'scale(' + scaleratio.tostring().replace(',','.') + ')'; //chrome , 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); homecoming (w1 - w2); }

jquery html css scaling

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -