【问题标题】:jquery cycle fade image position centerjquery循环淡入淡出图像位置中心
【发布时间】:2011-03-07 10:07:04
【问题描述】:

我正在使用 jQuery Cycle 插件来淡入淡出图像。我已经在 CMS 上构建了它来裁剪图像等。如果我有一个非常高的图像,我希望图像位于中心。该插件使用 position:absoulte;同时淡入淡出图像。我试过用左边编辑插件:50%;宽度:宽度的一半;但我真的无法让它发挥作用。还有其他我可以使用的插件吗?或者也许可以解决这个问题?

如果您使用 firebug,您可以看到插件如何使用 position:absolute; 设置图像样式

http://jquery.malsup.com/cycle/ http://jquery.malsup.com/cycle/basic.html

【问题讨论】:

  • 测试页在这里会有帮助。
  • 插件链接和您的代码将对您有所帮助
  • @Wayen Khan @expermientX 添加

标签: jquery image cycle fade


【解决方案1】:

尝试像这样为每个图像设置边距:

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);
});

这假设 div.slideshow 正在保存您的图像。
确保您定义,例如width: 250px; 在 css 中!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多