jquery cycle fade image position center
I am using the jQuery Cycle plugin to fade images in and out. I've built it on a CMS to crop the images, etc. If I have a really tall image I want the image to be positioned in the center. The plugin uses position:absoulte; while fading the images in and out. I've tried editing the plugin with the left:50%; width:half of width; but I can't really get it to work. Are there any other plugins I can use? or maybe a way arou开发者_C百科nd this?
If you firebug you can see how the plugin styles the image with position:absolute;
http://jquery.malsup.com/cycle/ http://jquery.malsup.com/cycle/basic.html
Try setting margin for each of the images like this:
var mainW= jQuery('.slideshow').width();
jQuery('.slideshow img').each(function(){
var imgW = jQuery(this).width();
var margL=0-(imgW-mainW)/2;
jQuery(this).css('marginLeft',margL);
});
This assumes div.slideshow is holding your images.
Make sure that you define, e.g. width: 250px; in css for it!
精彩评论