听起来您可能想使用其中一个 jquery 组合插件。
这是一个例子:http ://webdesigntunes.com/coding/jquery-filterable-portfolio/
您创建一些带有与您想要排序的类匹配的类标记的 html
<nav class="primary clearfix">
<ul>
<li><a href="#" class="selected" data-filter="*">All</a></li>
<li><a href="#" data-filter=".web">Web Design</a></li>
<li><a href="#" data-filter=".ill">Ilustration</a></li>
<li><a href="#" data-filter=".logo">Logo</a></li>
<li><a href="#" data-filter=".video">Video</a></li>
<li><a href="#" data-filter=".print">Print Design</a></li>
</ul>
</nav>
<section class="main">
<div class="portfolio">
<article class="entry video">
<a data-rel="prettyPhoto" href="http://vimeo.com/34266952">
<img src="images/portfolio/work1.jpg" alt="">
<span class="video-hover"></span>
</a>
</article>
<article class="entry web">
<a data-rel="prettyPhoto" href="images/portfolio/work2.jpg">
<img src="images/portfolio/work2.jpg" alt="">
<span class="magnifier"></span>
</a>
</article>
</section>
应用一些 .css 等。
然后使用同位素进行排序
var $container = $('.portfolio');
$container.isotope({
filter: '*',
animationOptions: {
duration: 750,
easing: 'linear',
queue: false,
}
});
$('nav.primary ul a').click(function(){
var selector = $(this).attr('data-filter');
$container.isotope({
filter: selector,
animationOptions: {
duration: 750,
easing: 'linear',
queue: false,
}
});
return false;
});
var $optionSets = $('nav.primary ul'),
$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('nav.primary ul');
$optionSet.find('.selected').removeClass('selected');
$this.addClass('selected');
});
查看演示,看看这是否是您所需要的:http ://webdesigntunes.com/tutorial/filterable/
http://isotope.metafizzy.co/