![]() |
| ||
| Moving div Background Position on Click I have a product image that is 4 images 'sewn together' http://www.flickr.com/photos/28033561@N03/3504394261/ I am going to set a div called ProductImage and then have the background of the div set to this image, but with only the top image showing. I then want to have a button for 'more views' and when this is clicked the background position shift to show the next part of the image showing a different view. What is a suitable way to do this, I am hoping it could be done with a combination of css and javascript. |
| ||
| Re: Moving div Background Position on Click Millsy, You just reinvented something called a Sprite! Put your adidas shoes image (shoes.jpg) in a folder named "images", then save the following code as eg. "myProduct.html", then browse it in your browser. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">You can style the button/link as you wish in CSS. Enjoy Airshow |
| ||
| Re: Moving div Background Position on Click Doh! Problems in Firefox. Maybe someone knows the workaround. I'll have another look at it tomorrow. Airshow |
| ||
| Re: Moving div Background Position on Click OK, this version has been tested in IE6, Firefox 3.0.10, Opera 9.01 (all under Win2000). We use a constructor to build the DOM elements within a nominated DIV. Thus the code can be reused to easily incorporate two or more sprites on the same page with very minimal additional HTML and javascript. For flexibility, we also compute background position at each rotation rather than rely on predefined CSS rules. Save image and html file as per version 1 above. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Airshow |
| ||
| Re: Moving div Background Position on Click Thanks guys thats awesome :icon_biggrin: |
| All times are GMT -4. The time now is 1:34 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC