2014-01-09 77 views
-1

我嘗試讓Featured Content Slider自動滾動的列表項它們突顯了。但是當我嘗試jQuery代碼時,我甚至不滾動內容。有人可能會幫我解決這個問題會更好。特色內容滑塊ScrollTo

我嘗試,

JS:

var container = $("#featured ul"); 
scrollTo = $('ul li.ui-tabs-active.ui-state-active');   
container.animate({ 
    scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop() 
}); 

其實際的代碼;

<div id="featured" > 
    <ul class="ui-tabs-nav"> 
     <li class="ui-tabs-nav-item" id="nav-fragment-1"><a href="#fragment-1"><img src="images/image1-small.jpg" alt="" /><span>15+ Excellent High Speed Photographs</span></a></li> 
     <li class="ui-tabs-nav-item" id="nav-fragment-2"><a href="#fragment-2"><img src="images/image2-small.jpg" alt="" /><span>20 Beautiful Long Exposure Photographs</span></a></li> 
     <li class="ui-tabs-nav-item" id="nav-fragment-3"><a href="#fragment-3"><img src="images/image3-small.jpg" alt="" /><span>35 Amazing Logo Designs</span></a></li> 
     <li class="ui-tabs-nav-item" id="nav-fragment-4"><a href="#fragment-4"><img src="images/image4-small.jpg" alt="" /><span>Create a Vintage Photograph in Photoshop</span></a></li> 
     <li class="ui-tabs-nav-item" id="nav-fragment-5"><a href="#fragment-5"><img src="images/image4-small.jpg" alt="" /><span>Create a Vintage Photograph in Photoshop</span></a></li> 
     <li class="ui-tabs-nav-item" id="nav-fragment-6"><a href="#fragment-6"><img src="images/image4-small.jpg" alt="" /><span>Create a Vintage Photograph in Photoshop</span></a></li> 
     <li class="ui-tabs-nav-item" id="nav-fragment-7"><a href="#fragment-7"><img src="images/image4-small.jpg" alt="" /><span>Create a Vintage Photograph in Photoshop</span></a></li> 
     <li class="ui-tabs-nav-item" id="nav-fragment-8"><a href="#fragment-8"><img src="images/image4-small.jpg" alt="" /><span>Create a Vintage Photograph in Photoshop</span></a></li> 
    </ul> 
    <!-- First Content --> 
    <div id="fragment-1" class="ui-tabs-panel" style=""> 
     <img src="images/image1.jpg" alt="" /> 
     <div class="info" > 
      <h2><a href="#" >15+ Excellent High Speed Photographs</a></h2> 
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla tincidunt condimentum lacus. Pellentesque ut diam....<a href="#" >read more</a></p> 
     </div> 
    </div> 
    <!-- Second Content --> 
    <div id="fragment-2" class="ui-tabs-panel ui-tabs-hide" style=""> 
     <img src="images/image2.jpg" alt="" /> 
     <div class="info" > 
      <h2><a href="#" >20 Beautiful Long Exposure Photographs</a></h2> 
      <p>Vestibulum leo quam, accumsan nec porttitor a, euismod ac tortor. Sed ipsum lorem, sagittis non egestas id, suscipit....<a href="#" >read more</a></p> 
     </div> 
    </div> 
    <!-- Third Content --> 
    <div id="fragment-3" class="ui-tabs-panel ui-tabs-hide" style=""> 
     <img src="images/image3.jpg" alt="" /> 
     <div class="info" > 
      <h2><a href="#" >35 Amazing Logo Designs</a></h2> 
      <p>liquam erat volutpat. Proin id volutpat nisi. Nulla facilisi. Curabitur facilisis sollicitudin ornare....<a href="#" >read more</a></p> 
     </div> 
    </div> 
    <!-- Fourth Content --> 
    <div id="fragment-4" class="ui-tabs-panel ui-tabs-hide" style=""> 
     <img src="images/image4.jpg" alt="" /> 
     <div class="info" > 
      <h2><a href="#" >Create a Vintage Photograph in Photoshop</a></h2> 
      <p>Quisque sed orci ut lacus viverra interdum ornare sed est. Donec porta, erat eu pretium luctus, leo augue sodales....<a href="#" >read more</a></p> 
     </div> 
    </div> 
    <!-- Fourth Content --> 
    <div id="fragment-5" class="ui-tabs-panel ui-tabs-hide" style=""> 
     <img src="images/image4.jpg" alt="" /> 
     <div class="info" > 
      <h2><a href="#" >Create a Vintage Photograph in Photoshop</a></h2> 
      <p>Quisque sed orci ut lacus viverra interdum ornare sed est. Donec porta, erat eu pretium luctus, leo augue sodales....<a href="#" >read more</a></p> 
     </div> 
    </div> 
    <!-- Fourth Content --> 
    <div id="fragment-6" class="ui-tabs-panel ui-tabs-hide" style=""> 
     <img src="images/image4.jpg" alt="" /> 
     <div class="info" > 
      <h2><a href="#" >Create a Vintage Photograph in Photoshop</a></h2> 
      <p>Quisque sed orci ut lacus viverra interdum ornare sed est. Donec porta, erat eu pretium luctus, leo augue sodales....<a href="#" >read more</a></p> 
     </div> 
    </div> 
    <!-- Fourth Content --> 
    <div id="fragment-7" class="ui-tabs-panel ui-tabs-hide" style=""> 
     <img src="images/image4.jpg" alt="" /> 
     <div class="info" > 
      <h2><a href="#" >Create a Vintage Photograph in Photoshop</a></h2> 
      <p>Quisque sed orci ut lacus viverra interdum ornare sed est. Donec porta, erat eu pretium luctus, leo augue sodales....<a href="#" >read more</a></p> 
     </div> 
    </div> 
    <!-- Fourth Content --> 
    <div id="fragment-8" class="ui-tabs-panel ui-tabs-hide" style=""> 
     <img src="images/image4.jpg" alt="" /> 
     <div class="info" > 
      <h2><a href="#" >Create a Vintage Photograph in Photoshop</a></h2> 
      <p>Quisque sed orci ut lacus viverra interdum ornare sed est. Donec porta, erat eu pretium luctus, leo augue sodales....<a href="#" >read more</a></p> 
     </div> 
    </div> 
</div> 

imnot這使GUD但我試圖把一個的jsfiddle - >http://jsfiddle.net/pS6Bh/

+0

你可以做一個http:/ /jsfiddle.net? –

+0

加入小提琴,請檢查是否正確 – rockStar

+0

你的意思是,自動滑不工作? –

回答

0

其背後的原因停止自動滾動是,jQuery的標籤死記硬背功能在最新版本的貶值。要使其工作,你應該使用jQuery UI Tabs從克里斯托弗McCulloh

這裏是一個Working Demo通過包括腳本

你也應該包括以下CSS

#featured li.ui-tabs-active{ 
    background:url('images/selected-item.gif') top left no-repeat;  
} 
#featured ul.ui-tabs-nav li.ui-tabs-active a{ 
    background:#ccc; 
} 
+0

謝謝兄弟,自動幻燈片也是在我​​身邊工作的事情是,當活動項目達到第5或第6項,它沒有顯示,因爲scrol欄不根據活動項目自動滾動。那是我的問題:c – rockStar