2014-01-23 151 views
0

我有一个照片库,包含8个不同的部分和8个链接。点击时的每个链接都会显示一个图库并隐藏使用JavaScript显示的任何内容。然而,因为我点击任何非默认的图库,所以我实现了这个隐藏/显示脚本,缩略图被切成两半。任何想法为什么会发生?照片库缩略图调整大小

这里是一个画廊的链接:http://www.searchtransparency.net/stackoverflow/photo-gallery-test.html

感谢。

显示/隐藏代码:

<script> 
    var gal=jQuery; 
    gal.noConflict(); 
    gal(document).ready(
     function(){ 
      gal("#lobby").PikaChoose({carousel:true}); 
      gal("#apartment-interiors").PikaChoose({carousel:true}); 
      gal("#penthouse").PikaChoose({carousel:true}); 
      gal("#roofdeck").PikaChoose({carousel:true}); 
      gal("#health-club").PikaChoose({carousel:true}); 
      gal("#garage").PikaChoose({carousel:true}); 
      gal("#galleria").PikaChoose({carousel:true}); 
      gal("#the-views").PikaChoose({carousel:true}); 
     }); 
</script> 
<script> 
function lobby() 
{ 
    document.getElementById('gallery-lobby').style.display = 'block'; 
    document.getElementById('gallery-apartment-interiors').style.display = 'none'; 
    document.getElementById('gallery-penthouse').style.display = 'none'; 
    document.getElementById('gallery-roofdeck').style.display = 'none'; 
    document.getElementById('gallery-health-club').style.display = 'none'; 
    document.getElementById('gallery-garage').style.display = 'none'; 
    document.getElementById('gallery-galleria').style.display = 'none'; 
    document.getElementById('gallery-the-views').style.display = 'none'; 
} 
function apartmentinteriors() 
{ 
    document.getElementById('gallery-lobby').style.display = 'none'; 
    document.getElementById('gallery-apartment-interiors').style.display = 'block'; 
    document.getElementById('gallery-penthouse').style.display = 'none'; 
    document.getElementById('gallery-roofdeck').style.display = 'none'; 
    document.getElementById('gallery-health-club').style.display = 'none'; 
    document.getElementById('gallery-garage').style.display = 'none'; 
    document.getElementById('gallery-galleria').style.display = 'none'; 
    document.getElementById('gallery-the-views').style.display = 'none'; 
} 
function penthouse() 
{ 
    document.getElementById('gallery-lobby').style.display = 'none'; 
    document.getElementById('gallery-apartment-interiors').style.display = 'none'; 
    document.getElementById('gallery-penthouse').style.display = 'block'; 
    document.getElementById('gallery-roofdeck').style.display = 'none'; 
    document.getElementById('gallery-health-club').style.display = 'none'; 
    document.getElementById('gallery-garage').style.display = 'none'; 
    document.getElementById('gallery-galleria').style.display = 'none'; 
    document.getElementById('gallery-the-views').style.display = 'none'; 
} 
function roofdeck() 
{ 
    document.getElementById('gallery-lobby').style.display = 'none'; 
    document.getElementById('gallery-apartment-interiors').style.display = 'none'; 
    document.getElementById('gallery-penthouse').style.display = 'none'; 
    document.getElementById('gallery-roofdeck').style.display = 'block'; 
    document.getElementById('gallery-health-club').style.display = 'none'; 
    document.getElementById('gallery-garage').style.display = 'none'; 
    document.getElementById('gallery-galleria').style.display = 'none'; 
    document.getElementById('gallery-the-views').style.display = 'none'; 
} 
function healthclub() 
{ 
    document.getElementById('gallery-lobby').style.display = 'none'; 
    document.getElementById('gallery-apartment-interiors').style.display = 'none'; 
    document.getElementById('gallery-penthouse').style.display = 'none'; 
    document.getElementById('gallery-roofdeck').style.display = 'none'; 
    document.getElementById('gallery-health-club').style.display = 'block'; 
    document.getElementById('gallery-garage').style.display = 'none'; 
    document.getElementById('gallery-galleria').style.display = 'none'; 
    document.getElementById('gallery-the-views').style.display = 'none'; 
} 
function garage() 
{ 
    document.getElementById('gallery-lobby').style.display = 'none'; 
    document.getElementById('gallery-apartment-interiors').style.display = 'none'; 
    document.getElementById('gallery-penthouse').style.display = 'none'; 
    document.getElementById('gallery-roofdeck').style.display = 'none'; 
    document.getElementById('gallery-health-club').style.display = 'none'; 
    document.getElementById('gallery-garage').style.display = 'block'; 
    document.getElementById('gallery-galleria').style.display = 'none'; 
    document.getElementById('gallery-the-views').style.display = 'none'; 
} 
function galleria() 
{ 
    document.getElementById('gallery-lobby').style.display = 'none'; 
    document.getElementById('gallery-apartment-interiors').style.display = 'none'; 
    document.getElementById('gallery-penthouse').style.display = 'none'; 
    document.getElementById('gallery-roofdeck').style.display = 'none'; 
    document.getElementById('gallery-health-club').style.display = 'none'; 
    document.getElementById('gallery-garage').style.display = 'none'; 
    document.getElementById('gallery-galleria').style.display = 'block'; 
    document.getElementById('gallery-the-views').style.display = 'none'; 
} 
function theviews() 
{ 
    document.getElementById('gallery-lobby').style.display = 'none'; 
    document.getElementById('gallery-apartment-interiors').style.display = 'none'; 
    document.getElementById('gallery-penthouse').style.display = 'none'; 
    document.getElementById('gallery-roofdeck').style.display = 'none'; 
    document.getElementById('gallery-health-club').style.display = 'none'; 
    document.getElementById('gallery-garage').style.display = 'none'; 
    document.getElementById('gallery-galleria').style.display = 'none'; 
    document.getElementById('gallery-the-views').style.display = 'block'; 
} 
</script> 

画廊代码:

<div id="gallery-lobby"> 
       <ul id="lobby"> 
        <li><a href="#"><img src="images/gallery/lobby/1.jpg" width="1000" height="600" alt="Photo 1"></a></li> 
        <li><a href="#"><img src="images/gallery/lobby/2.jpg" width="1000" height="600" alt="Photo 2"></a></li> 
        <li><a href="#"><img src="images/gallery/lobby/3.jpg" width="1000" height="600" alt="Photo 3"></a></li> 
       </ul> 
      </div> 

      <div id="gallery-apartment-interiors" style="display:none;"> 
       <ul id="apartment-interiors"> 
        <li><a href="#"><img src="images/gallery/apartment-interiors/1.jpg" width="1000" height="600" alt="Photo 1"></a></li> 
        <li><a href="#"><img src="images/gallery/apartment-interiors/2.jpg" width="1000" height="600" alt="Photo 2"></a></li> 
        <li><a href="#"><img src="images/gallery/apartment-interiors/3.jpg" width="1000" height="600" alt="Photo 3"></a></li> 
        <li><a href="#"><img src="images/gallery/apartment-interiors/4.jpg" width="1000" height="600" alt="Photo 4"></a></li> 
        <li><a href="#"><img src="images/gallery/apartment-interiors/5.jpg" width="1000" height="600" alt="Photo 5"></a></li> 
       </ul> 
      </div> 

      <div id="gallery-penthouse" style="display:none;"> 
       <ul id="penthouse"> 
        <li><a href="#"><img src="images/gallery/penthouse/1.jpg" width="1000" height="600" alt="Photo 1"></a></li> 
        <li><a href="#"><img src="images/gallery/penthouse/2.jpg" width="1000" height="600" alt="Photo 2"></a></li> 
        <li><a href="#"><img src="images/gallery/penthouse/3.jpg" width="1000" height="600" alt="Photo 3"></a></li> 
       </ul> 
      </div> 

      <div id="gallery-roofdeck" style="display:none;"> 
       <ul id="roofdeck"> 
        <li><a href="#"><img src="images/gallery/roofdeck/1.jpg" width="1000" height="600" alt="Photo 1"></a></li> 
        <li><a href="#"><img src="images/gallery/roofdeck/2.jpg" width="1000" height="600" alt="Photo 2"></a></li> 
        <li><a href="#"><img src="images/gallery/roofdeck/3.jpg" width="1000" height="600" alt="Photo 3"></a></li> 
        <li><a href="#"><img src="images/gallery/roofdeck/4.jpg" width="1000" height="600" alt="Photo 4"></a></li> 
        <li><a href="#"><img src="images/gallery/roofdeck/5.jpg" width="1000" height="600" alt="Photo 5"></a></li> 
        <li><a href="#"><img src="images/gallery/roofdeck/6.jpg" width="1000" height="600" alt="Photo 6"></a></li> 
        <li><a href="#"><img src="images/gallery/roofdeck/7.jpg" width="1000" height="600" alt="Photo 7"></a></li> 
       </ul> 
      </div> 

      <div id="gallery-health-club" style="display:none;"> 
       <ul id="health-club"> 
        <li><a href="#"><img src="images/gallery/health-club/1.jpg" width="1000" height="600" alt="Photo 1"></a></li> 
        <li><a href="#"><img src="images/gallery/health-club/2.jpg" width="1000" height="600" alt="Photo 2"></a></li> 
       </ul> 
      </div> 

      <div id="gallery-garage" style="display:none;"> 
       <ul id="garage"> 
        <li><a href="#"><img src="images/gallery/garage/1.jpg" width="1000" height="600" alt="Photo 1"></a></li> 
        <li><a href="#"><img src="images/gallery/garage/2.jpg" width="1000" height="600" alt="Photo 2"></a></li> 
        <li><a href="#"><img src="images/gallery/garage/3.jpg" width="1000" height="600" alt="Photo 3"></a></li> 
        <li><a href="#"><img src="images/gallery/garage/4.jpg" width="1000" height="600" alt="Photo 4"></a></li> 
        <li><a href="#"><img src="images/gallery/garage/5.jpg" width="1000" height="600" alt="Photo 5"></a></li> 
       </ul> 
      </div> 

      <div id="gallery-galleria" style="display:none;"> 
       <ul id="galleria"> 
        <li><a href="#"><img src="images/gallery/galleria/1.jpg" width="1000" height="600" alt="Photo 1"></a></li> 
        <li><a href="#"><img src="images/gallery/galleria/2.jpg" width="1000" height="600" alt="Photo 2"></a></li> 
        <li><a href="#"><img src="images/gallery/galleria/3.jpg" width="1000" height="600" alt="Photo 3"></a></li> 
       </ul> 
      </div> 

      <div id="gallery-the-views" style="display:none;"> 
       <ul id="the-views"> 
        <li><a href="#"><img src="images/gallery/the-views/1.jpg" width="1000" height="600" alt="Photo 1"></a></li> 
        <li><a href="#"><img src="images/gallery/the-views/2.jpg" width="1000" height="600" alt="Photo 2"></a></li> 
        <li><a href="#"><img src="images/gallery/the-views/3.jpg" width="1000" height="600" alt="Photo 3"></a></li> 
        <li><a href="#"><img src="images/gallery/the-views/4.jpg" width="1000" height="600" alt="Photo 4"></a></li> 
        <li><a href="#"><img src="images/gallery/the-views/5.jpg" width="1000" height="600" alt="Photo 5"></a></li> 
        <li><a href="#"><img src="images/gallery/the-views/6.jpg" width="1000" height="600" alt="Photo 6"></a></li> 
       </ul> 
      </div> 

      <br> 

      <p align="center"><a onClick="lobby()" href="#">Lobby</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onClick="apartmentinteriors()" href="#">Apartment Interiors</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onClick="penthouse()" href="#">Penthouse</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onClick="roofdeck()" href="#">Roofdeck</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onClick="healthclub()" href="#">Health Club</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onClick="garage()" href="#">Garage</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onClick="galleria()" href="#">Galleria</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onClick="theviews()" href="#">The Views</a></p> 

回答

0

这里是我的解决方案:

  1. 我改变风格= “显示:无;”在每个div上style =“height:0px; overflow:hidden;”
  2. 然后,我改变了JavaScript的

从这:

function lobby() 
{ 
    document.getElementById('gallery-lobby').style.display = 'block'; 
    document.getElementById('gallery-apartment-interiors').style.display = 'none'; 
    document.getElementById('gallery-penthouse').style.display = 'none'; 
    document.getElementById('gallery-roofdeck').style.display = 'none'; 
    document.getElementById('gallery-health-club').style.display = 'none'; 
    document.getElementById('gallery-garage').style.display = 'none'; 
    document.getElementById('gallery-galleria').style.display = 'none'; 
    document.getElementById('gallery-the-views').style.display = 'none'; 
} 

要这样:

function lobby() 
{ 
    document.getElementById('gallery-lobby').style.height = 'auto'; 
    document.getElementById('gallery-apartment-interiors').style.height = '0px'; 
    document.getElementById('gallery-penthouse').style.height = '0px'; 
    document.getElementById('gallery-roofdeck').style.height = '0px'; 
    document.getElementById('gallery-health-club').style.height = '0px'; 
    document.getElementById('gallery-garage').style.height = '0px'; 
    document.getElementById('gallery-galleria').style.height = '0px'; 
    document.getElementById('gallery-the-views').style.height = '0px'; 
} 

这解决了缩略图的问题得到推83px左侧。

0

它看起来像你使用是把一个左侧定位你的-83px的 “缩略图” 任何CSS。尝试删除该CSS条目。此外,它看起来像你使用1000×600像素的图像,我不知道这是否只是暂时的,但可能不是长期最好的想法。

或者试试:

.clip img{ 
    left: 0px; 
} 
+0

试过这个没有成功。当我删除style =“display:none;”时在包含div的缩略图是完美的。为什么1000像素×600像素的照片是一个坏主意? –

+0

@WolfCat你有每个图像的内联风格的左:-83px;'尝试从一些缩略图中删除它,它应该解决你的问题。 通常的做法是尽可能优化网站。您的缩略图是全尺寸的图像,在您的内联样式中被人为缩小。因此,他们需要更长的时间才能加载和消耗更多的带宽,而不是较小的优化图像。 – badAdviceGuy

+0

我甚至没有看到左侧:-83px;写在代码中。它似乎是自动生成的。所以我不知道如何改变它 –