2012-10-05 3 views
2

절대적으로 내 머리카락을 꺼냅니다. GitHub에는 흑백 솔루션이 제공되지 않는 것으로 보입니다.이 솔루션은 상당히 단순한 개념처럼 보이기 때문에 이상합니다. 아마 나는 그것을 얻지 못한다. 항목을 필터링 할 Isotope를 사용하여 -동위 원소 및 미디어 쿼리

기본적으로, 나는 유체반응 포트폴리오를 만들려고하고 있습니다. 필터링이 잘 작동하고 4 열은 완전히 유동적이며 창 크기를 조정하면 모든 것이 잘 어울립니다.

그러나는 모바일 및 태블릿 레이아웃에 대해, I 단순히 2 열 레이아웃에 4 열 레이아웃에서 적응할 필요가있다. ..

$(window).load(function(){ 

    var $container = $('#thumbs'); 
    $container.isotope({ 
     filter: '*', 
     animationOptions: { 
      duration: 750, 
      easing: 'linear', 
      queue: false, 
     }, 
    }); 

    // initialize Isotope 
    $container.isotope({ 
     // options... 
     resizable: false, // disable normal resizing 
     // set columnWidth to a percentage of container width 
     masonry: { columnWidth: $container.width()/4 }, 
    }); 

    // update columnWidth on window resize 
    $(window).smartresize(function(){ 
     $container.isotope({ 
      // update columnWidth to a percentage of container width 
      masonry: { columnWidth: $container.width()/4 } 
     }); 
    }); 

// My attempt at using media queries to change 'columnWidth' 
    $(window).resize(function() { 
     var width = $(window).width(); 
     if (width < 768) { 
      $container.isotope({ 
       // update columnWidth to half of container width 
       masonry: { columnWidth: $container.width()/2 } 
      }); 
     } 
    }); 
}); 

작동하지 않았다 :(

어떤 도움이 많이 주시면 감사하겠습니다

답변

2

이 열 번호를 설정하는 작업을해야 그럼 당신은 그냥 분할 :

나는이 시도 columns.

var columns; 

// set column number 
setColumns(); 

// rerun function when window is resized 
$(window).on('resize', function() { 
    setColumns(); 
}); 

// the function to decide the number of columns 
function setColumns() { 
    if($(window).width() <= 768) { 
    columns = 2; 
    } else { 
    columns = 4; 
    } 
} 
+0

감사합니다. 전설. – Salmonface

+0

나는 왜 광산이 작동하지 않았는지 깨달았다. 'columns : 4 대신에'{masonry : {columnWidth : $ container.width()/4}'를 사용하고있는'$ container.isotope ({'함수)에서 다시 정렬 해 주셔서 고맙습니다 .. – Salmonface

+0

안녕하세요 @Salmonface 같은 문제가 있는데, 창을 축소하면 레이아웃을 두 개의 열로 바꿀 수 있습니다. 어떻게 수정 했습니까? var $ container = $ ('# filter_container'); $ container.isotope ({ itemSelector : 거짓, // 정상 크기 조정 벽돌을 사용하지 : \t \t 크기 조정, '.element {columnWidth의 : $의 container.width()/3} \t \t \t \t }); 창 resiz에 \t \t // 갱신 columnWidth의 전자 \t \t $ (창) .smartresize (함수() {컨테이너 폭 \t \t \t 벽돌의 비율에 \t \t $의 container.isotope ({ \t \t \t // 갱신 columnWidth의 : {columnWidth의 : $ 컨테이너. 폭()/3} \t \t}); ; \t \t})' – Grundizer