2014-01-23 3 views
0

У меня есть фотогалерея с 8 различными разделами и 8 ссылками под ним. Каждая ссылка при нажатии показывает галерею и скрывает, которые когда-либо показываются с помощью javascript. Однако, поскольку я реализовал этот скрипт hide/show, когда я нажимаю на любую галерею, отличную от стандартной, миниатюры обрабатываются пополам. Любые идеи, почему это происходит?Фотогалерея Миниатюры Изменение размера

Вот ссылка на галерею: 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. Тогда я изменил яваскрипт

От этого:

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

Похоже, все, что CSS вы используете, положив левую позиционирование на ваших "миниатюр" в -83px. Попробуйте удалить эту запись CSS. Также похоже, что вы используете изображения размером 1000 на 600 пикселей, я не знаю, является ли это временной, но, вероятно, не лучшей идеей в долгосрочной перспективе.

Или попробуйте:

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

Пробовал это без успеха. Когда я удаляю style = "display: none;" на содержащихся divs миниатюры идеальны. Почему фотографии 1000px на 600px плохой идеей? –

+0

@WolfCat у вас есть все изображения с встроенным стилем 'left: -83px;' попробуйте удалить это из некоторых миниатюр, и это должно исправить вашу проблему. Общей практикой является оптимизация сайта как можно лучше. Ваши эскизы - это полноразмерные изображения, которые искусственно измеряются в ваших встроенных стилях. Поэтому им потребуется больше времени для загрузки и съедания большей полосы пропускания, чем меньшего оптимизированного изображения. – badAdviceGuy

+0

Я даже не вижу, где слева: -83px; написано в коде. Кажется, он автоматически генерируется. Поэтому я не уверен, как его изменить –

Смежные вопросы