我正在使用流沙和jquery在可过滤的网站上工作。我已经设置了一切(imgs现在是通用的)。在一组图像上方有一组类别,当您选择一个类别时,只显示该类别中的项目。它会过滤并显示正确的项目,但在过滤时会以非常笨拙的方式上下跳动 - 当它应该缓和时。
链接为http://lllh.dk/filtering/work3.html
部分HTML:
<div id="content">
<div class="txtdiv">
<h1>A selection of work</h1>
<h2>2009-present</h2>
</div>
<div id="workleft">
<ul class="filterOptions">
<txt>
<li class="active"><a href="#" class="all">All</a></li>
<li><a href="#" class="graphicdesign">Graphic Design</a></li>
<li><a href="#" class="printmatters">Design of Printed Matters</a></li>
<li><a href="#" class="designlanguages">Design for Languages</a></li>
<li><a href="#" class="typo">Typography and Lettering</a></li>
<li><a href="#" class="visualidentity">Visual Identity</a></li>
</txt>
</ul>
</div>
<div id="workright">
<ul class="filterOptions">
<txt>
<li><a href="#" class="photo">Photography</a></li>
<li><a href="#" class="camless">Cameraless Photography</a></li>
<li><a href="#" class="co-socialdesign">Co-Design / Social Design</a></li>
<li><a href="#" class="conceptualdesign">Conceptual Design</a></li>
<li><a href="#" class="criticaldesign">Critical Design</a></li>
</txt>
</ul>
</div>
<div class="workdiv">
<ul class="ourHolder">
<li class="item" data-id="id-1" data-type="graphicdesign typo">
<a href="work/braille_calendar.html" onMouseOver="document.braille.src='workbuttons/braille2.jpg';" onMouseOut="document.braille.src='workbuttons/braille1.jpg';"> <img src="workbuttons/braille1.jpg" name="braille"> </a>
</li>
<li class="item" data-id="id-3" data-type="camless photo">
<a href="work/braille_calendar.html" onMouseOver="document.RapaNui.src='workbuttons/braille2.jpg';" onMouseOut="document.RapaNui.src='workbuttons/braille1.jpg';"> <img src="workbuttons/braille1.jpg" name="RapaNui"> </a>
</li>
<li class="item" data-id="id-2" data-type="graphicdesign">
<a href="work/braille_calendar.html" onMouseOver="document.Name.src='workbuttons/braille2.jpg';" onMouseOut="document.Name.src='workbuttons/braille1.jpg';"> <img src="workbuttons/braille1.jpg" name="Name"> </a>
</li>
<li class="item" data-id="id-2" data-type="typo">
<a href="work/braille_calendar.html" onMouseOver="document.Something.src='workbuttons/braille2.jpg';" onMouseOut="document.Something.src='workbuttons/braille1.jpg';"> <img src="workbuttons/braille1.jpg" name="Something"> </a>
</li>
</ul>
</div>
</div>
和一些css
/* Load headline fonts */
@font-face {
font-family: 'ACPRegular';
src: url('acaslonpro-regular-webfont.eot');
src: url('acaslonpro-regular-webfont.eot?#iefix') format('embedded-opentype'),
url('acaslonpro-regular-webfont.woff') format('woff'),
url('acaslonpro-regular-webfont.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'ACPBold';
src: url('acaslonpro-bold-webfont.eot');
src: url('acaslonpro-bold-webfont.eot?#iefix') format('embedded-opentype'),
url('acaslonpro-bold-webfont.woff') format('woff'),
url('acaslonpro-bold-webfont.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
/* Page content */
#content {
margin-top:75px;
position:absolute;
width:850px;
z-index:0;
border-bottom:45px;
border-bottom-style:solid;
border-bottom-color:#FFF;
}
.txtdiv {
width:400px;
margin: 0px auto 0px auto;
text-align:center;
}
/* Typography */
h1 {
font-family:ACPBold;
letter-spacing:1px;
font-size:2em;
font-weight:normal;
padding:0px;
margin:0px;
margin-bottom:3px;
}
h2 {
font-family:ACPRegular;
font-size:1.2em;
font-weight:normal;
padding:0px;
margin-top:0px;
margin-bottom:15px;
}
txt {
font-family:Arial, Helvetica, sans-serif;
font-size:0.7em;
line-height:160%;
margin-left:auto;
margin-right:auto;
}
ul {
list-style-type: none;
padding: 0px;
margin: 0px;
overflow: auto;
}
/* Work page */
#workleft {
width:421px;
margin: 0px 8px 0px 0px;
text-align:right;
float:left;
}
#workright {
width:421px;
text-align:left;
overflow:hidden;
}
.workdiv {
width:741px;
margin: 0px auto 0px auto;
margin-top:45px;
}
/*- PORTFOLIO -*/
ul.ourHolder {
width: 800px;
height: 850px;
overflow: hidden;
}
ul.ourHolder li.item {
width: 247px;
height: 164px;
float: left;
text-align: center;
overflow: hidden;
}
最后是js ..
$(document).ready(function() {
// get the action filter option item on page load
var $filterType = $('.filterOptions li.active a').attr('class');
// get and assign the portfolio element to the
// $holder varible for use later
var $holder = $('ul.ourHolder');
// clone all items within the pre-assigned $holder element
var $data = $holder.clone();
// attempt to call Quicksand when a filter option
// item is clicked
$('.filterOptions li a').click(function(e) {
// reset the active class on all the buttons
$('.filterOptions li').removeClass('active');
// assign the class of the clicked filter option
// element to our $filterType variable
var $filterType = $(this).attr('class');
$(this).parent().addClass('active');
if ($filterType == 'all') {
// assign all li items to the $filteredData var when
// the 'All' filter option is clicked
var $filteredData = $data.find('li');
}
else {
// find all li elements that have our required $filterType
// values for the data-type element
var $filteredData = $data.find('li[data-type~=' + $filterType + ']');
}
// call quicksand and assign transition parameters
$holder.quicksand($filteredData, {
duration: 800,
easing: 'easeInOutQuad'
});
return false;
});
});
似乎不知何故布局的一部分扰乱了宽松。在我尝试进行故障排除时,似乎图像上方的部分内容是问题,也许是txtdiv div。如果我删除除适用于过滤器函数的css之外的所有css,则缓动和过滤工作正常。
答案 0 :(得分:0)
我知道这个问题。 这是一个问题: CSS bubbling while using jQuery Quicksand
对我而言,当我改变多条css线时它是有效的。但我不知道了,也许你可以查看来源:http://www.annagebhardt.de/(看点效果点击'PROJEKTE'然后是子条目)
答案 1 :(得分:0)
评论$(this).parent().addClass('active');
并将adjustHeight: false
添加到流沙的选项中为我工作。