全幅グリッドシステムにアイソトープを使用しています。希望どおりに動作するようになりましたが、レスポンシブ要素にいくつか問題があります。システムに対して 4,3,2,1 のアプローチを取りたいと考えています。デスクトップ用に 4 アイテム、タブレット用に 3 アイテム、Mob ランドスケープ用に 2 アイテム、Mob ポートレート用に 1 アイテム。
何を試しても、サイズ変更時に奇妙なレイアウトが表示されます。作業に最も近いのは次のコードを使用することですが、ウィンドウのサイズを変更すると、要素が新しい行に落ちて、グリッド間に大きなギャップが生じることがあります。グリッドをシームレスにしたい。
これは私のコードです:
<script>
var $container = $('#isotope')
$container.imagesLoaded( function(){
$('#isotope').isotope({
// options
animationEngine : 'best-available',
layoutmode: 'masonry',
filter: '.all-header, .project, .clients, .news, .blog'
});
});
// initialize Isotope
$container.isotope({
// options...
resizable: true, // disable normal resizing
// set columnWidth to a percentage of container width
masonry: { columnWidth: $container.width() / 25 }
});
// update columnWidth on window resize
$(window).smartresize(function(){
$container.isotope({
// update columnWidth to a percentage of container width
masonry: { columnWidth: $container.width() / 25 }
});
});
var $optionSets = $('#filter_bar .option-set'),
$optionLinks = $optionSets.find('a');
$optionLinks.click(function(){
var $this = $(this);
// don't proceed if already selected
if ( $this.hasClass('selected') ) {
return false;
}
var $optionSet = $this.parents('.option-set');
$optionSet.find('.selected').removeClass('selected');
$this.addClass('selected');
// make option object dynamically, i.e. { filter: '.my-filter-class' }
var options = {},
key = $optionSet.attr('data-option-key'),
value = $this.attr('data-option-value');
// parse 'false' as false boolean
value = value === 'false' ? false : value;
options[ key ] = value;
if ( key === 'layoutMode' && typeof changeLayoutMode === 'function' ) {
// changes in layout modes need extra logic
changeLayoutMode( $this, options )
} else {
// otherwise, apply new options
$container.isotope( options );
}
return false;
});
</script>