0

我有这个结构:

<div style="background-color:#FFF;height:49px;border-top:1px solid #ef4723;clear:both">
  <div id="marka-slider" class="row">
    <ul>
      <?php if (($references = Reference::getAll())) :
              foreach ($references as $r) :
      ?>
        <li>
          <img src="<?php echo Reference::getUploadPath() . '/' . $r->mediapath; ?>"
               alt="<?php echo $r->title; ?>" title="<?php echo $r->title; ?>"/>
               <!-- <?php CVarDumper::dump(array('ref: ' => $r->attributes), 5, 1); ?>  -->
        </li>
      <?php endforeach; ?>
      <?php endif; ?>
    </ul>

  </div>
</div>

JS:

var slider;
$(document).ready(function () {
  slider = $('#marka-slider ul li');

  setTimeout(function() {
    bgscroll('right');
  }, 1000);
});

function bgscroll(direction) {
  var sign;
    if (direction === 'left') {
      slider.stop().animate({'background-position': '+=10000'}, 200000, 'linear', bgscroll);
    } else {
      slider.stop().animate({'background-position': '-=10000'}, 200000, 'linear', bgscroll);
    }

但它不起作用。当我通过 Firebug 检查时,它没有给出错误。我该如何解决?

演示

4

1 回答 1

0

http://jsfiddle.net/xpVRT/2/

您正在为标签的背景图像设置动画li,而图像liimg标签内部。

于 2013-04-02T11:51:36.407 回答