【问题标题】:jQuery Cycle in an horizontal scrollable div: IE problem水平可滚动 div 中的 jQuery 循环:IE 问题
【发布时间】:2013-09-29 22:45:08
【问题描述】:

我在 IE 6 和 7 中遇到了一个问题,即在水平可滚动 div 中嵌入了 Cycle 幻灯片。我已经使用这种技术(http://www.switchonthecode.com/tutorials/using-jquery-slider-to-scroll-a-div)来创建水平可滚动的 div。我会将 Cycle 幻灯片嵌入到可滚动的 div 中。在 FF3、Opera、Chrome 中都可以正常工作。在 IE 6 和 7 中,图像容器和导航缩略图是固定的,它们不会滚动。可滚动 div 中的所有其他 div 或元素都可以正常工作。

这是我的代码:

<div id="content">
  <div id="contentscroll">
    <div id="contentholder">

      <div class="contentitem">
        <span class="name">ABC</span>
        <span class="price">25 €</span>
    <div class="photo">
          <img src="642_03_prod[1].png" height="280" width="280" />
          <img src="855_02_prod[1].png" height="280" width="280" />
          <img src="856_01_prod[1].png" height="280" width="280" />
        </div>
        <ul class="colors">
          <li><a href="#"><img src="642_03_prod[1].png" height="25" width="25" /></a></li>
          <li><a href="#"><img src="855_02_prod[1].png" height="25" width="25" /></a></li>
          <li><a href="#"><img src="856_01_prod[1].png" height="25" width="25" /></a></li>
        </ul>
      </div>

      <!--- other contentitem --->

    </div> <!--- end contentholder --->
  </div> <!--- end contentscroll --->
</div> <!--- end content --->

这是 CSS:

#contentscroll {
    background: transparent;
    width: 990px;
    height: 386px;
    overflow: hidden;
}

#contentholder {
  width: 1500px;
  height: 386px;
}

.contentitem {
  width: 330px;
  height: 100%;
  padding: 0;
  float: left;
}

.contentitem .name, .contentitem .price {
  width: 330px;
  height: 18px;
  margin:0;
  padding: 0;
  float: left;
  text-align:center;
  font:12px Arial, Helvetica, sans-serif;
  color: #FFF;
}

.photo{
    height: 280px;
}

ul.colors { margin:0; padding:0; height: 18px;}
ul.colors { list-style-type: none; display: inline; margin:0; padding:0; }
ul.colors li { background: none; display: inline; margin: 0; padding: 0; }
ul.colors li a { background: none; border: 0; margin: 0; margin-right: 2px; padding:0; color: #FFF;}
ul.colors li a img { background: none; border: 0; margin: 0; padding:0; }

这是JS:

$('.photo').cycle({ 
    fx:     'turnDown', 
    speed:  'fast', 
    timeout: 0, 
    pager:  '.colors',
    fastOnEvent: true,
    slideExpr:     null,
    cleartype:  true,
    cleartypeNoBg:  true,
    pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
        return '.colors li:eq(' + idx + ') a'; 
} 
});

谁能帮帮我? Cycle 是否将 CSS 属性应用于 .photo 和 .colors 并且这个事实造成了这个问题? .name span e .price span 滚动。

【问题讨论】:

    标签: jquery


    【解决方案1】:

    我已经用DebugBar控制了:循环添加一些样式和属性:

    <DIV class=photo style="WIDTH: 280px; POSITION: relative; HEIGHT: 280px" cycleStop="0" cyclePause="0" cycleTimeout="0" jQuery1245766927421="13">
    
    <IMG style="DISPLAY: none; Z-INDEX: 3; LEFT: 0px; ZOOM: 1; POSITION: absolute; TOP: 280px; HEIGHT: 0px" height=280 src="642_03_prod[1].png" width=280 cycleH="280" cycleW="280" jQuery1245766927421="10">
    <IMG style="DISPLAY: block; Z-INDEX: 4; LEFT: 0px; WIDTH: 280px; ZOOM: 1; POSITION: absolute; TOP: 0px; HEIGHT: 280px" height=280 src="855_02_prod[1].png" width=280 cycleH="280" cycleW="280" jQuery1245766927421="11">
    <IMG style="DISPLAY: none; Z-INDEX: 1; LEFT: 0px; POSITION: absolute; TOP: 0px; HEIGHT: 0px" height=280 src="856_01_prod[1].png" width=280 cycleH="280" cycleW="280" jQuery1245766927421="12">
    
    </DIV>
    

    images div 容器上有一个position:relative,imgs 上有一个position: absolute, display: block。 我认为这些属性是造成问题的原因,但我不知道如何删除它们。

    【讨论】:

      【解决方案2】:

      文件 jquery.cycle.all.js:

      第 187 行:

      // container requires non-static position so that slides can be position within
          if ($cont.css('position') == 'static')
              $cont.css('position', 'relative');
      

      第 212 行:

      // set position and zIndex on all the slides
          $slides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) {
              var z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i;
              $(this).css('z-index', z)
          });
      

      我认为JS的这两部分对于解决问题很重要,但我不知道如何。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-04-27
        • 2011-05-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-06-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多