2013-02-15 402 views
-2

我希望當用戶點擊圖庫上的縮略圖時,頁面應該自動滾動到頂部。這裏是代碼:滾動到頂部代碼

<div id="gallery" class="content"> 
        <div class="wrapper"> 
         <div class="slideshow-c``ontainer"> 
          <div id="slideshow" class="slideshow"></div> 
         </div> 
        </div> 
       </div> 
       <div id="thumbs" class="navigation"> 
        <h3>Gallery</h3> 
        <ul class="thumbs noscript"> 
         <li> 
          <a class="thumb" href="images/slider-img1.jpg" title=""> <img src="images/page1-img1.jpg" alt="" /><span></span> </a> 
         </li> 
         <li> 
          <a class="thumb" href="images/slider-img2.jpg" title=""> <img src="images/page2-img1.jpg" alt="" /> <span></span></a> 
         </li> 
         <li> 
          <a class="thumb" href="images/slider-img3.jpg" title=""> <img src="images/page2-img2.jpg" alt="" /> <span></span></a> 
         </li> 
         <li class="last"> 
          <a class="thumb" href="images/slider-img4.jpg" title=""> <img src="images/page3-img1.jpg" alt="" /> <span></span></a> 
         </li> 
         <li> 
          <a class="thumb" href="images/slider-img5.jpg" title=""> <img src="images/page1-img2.jpg" alt="" /> <span></span></a> 
         </li> 
         <li> 
          <a class="thumb" href="images/slider-img6.jpg" title=""> <img src="images/page1-img3.jpg" alt="" /> <span></span></a> 
         </li> 
         <li> 
          <a class="thumb" href="images/slider-img7.jpg" title=""> <img src="images/page1-img4.jpg" alt="" /><span></span> </a> 
         </li> 
         <li class="last"> 
          <a class="thumb" href="images/slider-img8.jpg" title=""> <img src="images/page1-img5.jpg" alt="" /> <span></span></a> 
         </li> 
         <li> 
          <a class="thumb" href="images/slider-img9.jpg" title=""> <img src="images/page1-img6.jpg" alt="" /><span></span> </a> 
         </li> 
         <li> 
          <a class="thumb" href="images/slider-img10.jpg" title=""> <img src="images/page1-img7.jpg" alt="" /> <span></span></a> 
         </li> 
         <li> 
          <a class="thumb" href="images/slider-img11.jpg" title=""> <img src="images/page1-img8.jpg" alt="" /> <span></span></a> 
         </li> 
         <li class="last"> 
          <a class="thumb" href="images/slider-img12.jpg" title=""> <img src="images/page1-img9.jpg" alt="" /> <span></span></a> 
         </li> 
         <li class="last2"> 
          <a class="thumb" href="images/slider-img13.jpg" title=""> <img src="images/page1-img10.jpg" alt="" /> <span></span></a> 
         </li> 
         <li class="last2"> 
          <a class="thumb" href="images/slider-img14.jpg" title=""> <img src="images/page1-img11.jpg" alt="" /> <span></span></a> 
         </li> 
         <li class="last2"> 
          <a class="thumb" href="images/slider-img15.jpg" title=""> <img src="images/page1-img12.jpg" alt="" /><span></span> </a> 
         </li> 
         <li class="last last2"> 
          <a class="thumb" href="images/slider-img16.jpg" title=""> <img src="images/page1-img13.jpg" alt="" /> <span></span></a> 
         </li> 

        </ul> 
       </div> 
      </div> 
     </div> 
     <div class="block"></div> 

回答

0

你有你的href在你的標籤設置爲圖像本身。是不是隻是在自己的網頁上加載圖像?

您可以使用ID來定位頁面的特定區域以滾動到。

<a href="#someid">Scroll</a> 

More page content 

<div id="someid"> 
    Content to scroll too 
</div> 
+0

是的,它加載在它自己的頁面上,所以當圖片被點擊時它應該加載並且同時頁面應該滾動到頂部,這是可能的嗎? – user2077202 2013-02-15 22:53:01

+0

我不確定我是否理解。如果圖像加載到自己的窗口中,是否應該不滾動到新頁面的頂部? – Phil 2013-02-16 00:58:55

+0

http://lashstudio.comuf.com/gallery.html這是網站和畫廊,也許你會明白 – user2077202 2013-02-16 10:09:42