Note that there are some explanatory texts on larger screens.

plurals
  1. POAspect ratio of an image while filling screen and scrolling
    primarykey
    data
    text
    <p>I am working on a site which can be found running at www.musidoraland.co.uk. I have four pictures that I need to fill the background whatever the screen size and still retain their aspect ratio, at the moment they are stretched or squished. However I am also using javascript to scroll the images and find that anything I try to keep aspect ratio tends to stop the scrolling or just not work. I would really apreciate any help, suggestions or advice anyone might have, and thank you in advance. My code is (containing javascript I thought might work but doesn't):</p> <p>Html:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;meta name="description" content="Beauchamp&amp;#39;s Corporate offers a unique service for clients wishing to design a special product for their business."&gt; &lt;title&gt;Beauchamp&amp;#39;s Corporate&lt;/title&gt; &lt;link rel="stylesheet" href="css/style.css" type="text/css" /&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="transify.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $('#maximage').cycle({ fx: 'scrollHorz', // choose your transition type, ex: fade, scrollUp, shuffle, etc... speed: 1000, timeout: 7000, prev: '#arrow_left', next: '#arrow_right' }); $('#content').transify({opacityOrig:.7}); $('#menu li').transify({opacityOrig:.7}); }); var theWindow = $(window), $bg = $("#maximage"), aspectRatio = $bg.width() / $bg.height(); function resizeBg() { if ( (theWindow.width() / theWindow.height()) &lt; aspectRatio ) { $bg .removeClass() .addClass('bgheight'); } else { $bg .removeClass() .addClass('bgwidth'); } } theWindow.resize(function() { resizeBg(); }).trigger("resize"); &lt;/script&gt; &lt;body&gt; &lt;div id="logo" style="position:relative;"&gt; &lt;img src="images/logo8.png" alt="Beauchamp's Corporate" width="300px" style="position:absolute;"&gt; &lt;/div&gt; &lt;div id="cycle-loader"&gt; &lt;/div&gt; &lt;div id="maximage"&gt; &lt;img src="images/luggagelabel5.jpg" alt="" /&gt; &lt;img src="images/wallet2.jpg" alt="" /&gt; &lt;img src="images/luggagelabel4.jpg" alt="" /&gt; &lt;img src="images/coasters2.jpg" alt="" /&gt; &lt;/div&gt; &lt;a href="" id="arrow_left" class="button trans" title="Previous Photo"&gt;&lt;/a&gt; &lt;a href="" id="arrow_right" class="button trans" title="Next Photo"&gt;&lt;/a&gt; &lt;div id="pages"&gt; &lt;div id="nav"&gt; &lt;ul id="menu"&gt; &lt;li id="product"&gt;Our Product&lt;/li&gt; &lt;li id="contact"&gt;Contact Us&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div id="content"&gt; &lt;div id="copy"&gt; &lt;div class="page product"&gt; &lt;p&gt;We offer a consultation meeting in which we discuss client requirements, design ideas, packaging options, budgets, lead times and more... &lt;br /&gt; We have a number of designs already in production which we can edit &amp; brand with the client logo or... &lt;br /&gt; Following this initial meeting, we produce product drawings, quotes, source leather samples and materials specific to this product. Samples can be produced once drawings have been approved by the client. &lt;br /&gt; Lead times, delivery schedules and product prices are unique to the client and indervidually calculated according to the specific client reqirements. &lt;br /&gt; Where possible Beauchamp&amp;#39;s aims to produce products in one of our UK factories however should it be required we will use factories further afield. &lt;/p&gt; &lt;/div&gt; &lt;div class="page contact"&gt; &lt;p&gt;For further information: &lt;br /&gt; &lt;em&gt;Email:&lt;/em&gt; &lt;a href="info@beauchampsoflondon.com"&gt;info@beauchampsoflondon.com&lt;/a&gt; &lt;br /&gt; &lt;em&gt;Address:&lt;/em&gt; 35 Bruton Street, London, W1J 6QY &lt;br /&gt; &lt;em&gt;Website:&lt;/em&gt; &lt;a href="www.beauchampscorporate.com"&gt;www.beauchampscorporate.com&lt;/a&gt; &lt;br /&gt; &lt;em&gt;Fashion Accessories Website:&lt;/em&gt; &lt;a href="www.beauchampsoflondon.com"&gt;www.beauchampsoflondon.com&lt;/a&gt;&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; $.extend(jQuery.easing, { easeInOutQuart: function(x, t, b, c, d) { if ((t /= d / 2) &lt; 1) return c / 2 * t * t * t * t + b; return - c / 2 * ((t -= 2) * t * t * t - 2) + b; } }); $(function() { $('.page').hide(); $('#menu li').click( function() { var content_id = $(this).attr('id'); $('#menu li').addClass('off'); $(this).removeClass('off'); if ($('.page').is(':visible')) { $('.page').hide(); $('.'+content_id).show(); } else { $('#pages').animate({ height: '300px', easing: 'easeInOutQuart' }); console.log($(this).attr('id')); $('.'+content_id).show(); } }); }); $(function() { var open = false; $('#maximage').click( function() { $('#pages').animate({ height: '40px', easing: 'easeInOutQuart' }, function(){ $('.page').hide(); $('#menu li').removeClass('off'); }); }); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>CSS:</p> <pre><code> body { margin:0; padding:0; background: #FFFFFF; } #logo{ width:300px; height:149px; margin-left:auto; margin-right:auto; margin-top:0px; } a.button { display:block; width:50px; height:50px; margin-top:200px; opacity: 0.6%; } a#arrow_left{ float:left; background: url('../images/arrowleft1.jpg') no-repeat; position: relative; z-index: 100; } a#arrow_right{ float:right; background: url('../images/arrowright1.jpg') no-repeat; position: relative; z-index: 100; } .trans { zoom: 1; filter: alpha(opacity=50); opacity: 0.5; } #maximage { height: 100%; width: 100%; position: absolute; top: 0; left: 0; z-index: -5000; } #maximage img { width: 100%; height: 100%; position: absolute; top: 0; left: 0; z-index: -5000; } #pages { margin:0px; width:100%; padding:0px; bottom:0; position:fixed; text-align:center; height:40px; } #pages #content { margin:0; font-size: 18px; } #content { width:100%; padding:0px; background: url('../images/transparent.jpg') repeat; overflow:hidden; } .product { padding:0px 0px 0px 0px; } .contact { padding:40px 0px 120px 0px; } #nav { margin:0px auto 0px auto; width:912px; padding:0px; text-align:center; overflow:hidden; } #menu { clear:both; width:369px; margin:0 auto; } #menu li { font-family: Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", Georgia, serif; float:left; width:auto; background: #A68538 repeat; margin-right:0px; cursor:pointer; } #menu li#contact { margin:0; border-left: none; } li { background: #A68538; list-style: none; border: 1px solid #000000 ; width:150px; text-align:center; padding:10px; display:inline; } #copy { width:700px; margin: 0 auto 0 auto; } em { font-style: normal; font-weight: bold; } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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