Hi - can someone please explain to me why there is relative positioning here, because when I remove it it has no affect visually, and usually you have an absolute positioning that goes along with relative, but there is none here.
Code CSS:#gallery { background-color:#94C5EB; border:1px solid #015287; height:103px; width: 325px; overflow: auto; text-align:center; position: relative; margin-bottom: 10px; } #gallery img { width: 97px; height: 97px; float:left; border:1px solid #fff; padding:2px; } h2 { clear: both; } #ajaxInProgress{ width:325px; height:13px; padding: 2px 0; margin-top:-5px; } .progress { background: #fff url(progress.gif) no-repeat center right; }
Code HTML4Strict:<div id="content"> <h2> Image Gallery </h2> <div id="ajaxInProgress"></div> <div id="gallery"> <img src="../../images/beau_200.jpg" alt="" /> <img src="../../images/fader_200.jpg" alt="" /> <img src="../../images/kellie_200.jpg" alt="" /> <img src="../../images/mofat_200.jpg" alt="" /> <img src="../../images/johnny_200.jpg" alt="" /> <img src="../../images/glenda_200.jpg" alt="" /> </div> <h2> Welcome </h2>
Code JavaScript:$(document).ready(function(){ $('#ajaxInProgress') .ajaxStart(function() { $(this).addClass('progress'); }) .ajaxStop( function(){ $(this).removeClass('progress'); }); GALLERY.init(); }); var GALLERY = { container: '#gallery', url: 'getImages', delay: 5000, running: false, init: function() { var _gallery = this; $(this.container).scroll(function() { _gallery.checkScroll(); }); }, checkScroll: function() { var gallery_div = $(this.container); if(gallery_div[0].scrollHeight - gallery_div.height() - gallery_div.scrollTop() <= 0) { this.load(); } }, load: function() { // Don't call if we're already running! if(this.running) { return; } this.running = true; var _gallery = this; $.ajax({ type:"get", url: this.url, success: function(data){ var images = data.split('|'); $.each(images, function() { _gallery.display(this); }); }, complete: function() { _gallery.running = false; } }); }, display: function(image_url) { $('<img></img>') .attr('src', '../../images/' + image_url) .hide() .load(function() { $(this).fadeIn(); }) .appendTo('#gallery'); } }




Reply With Quote




Bookmarks