使用流沙进行过滤时,所有图像都会在跳入位置之前以跳跃开始。我在这里阅读了很多q& a,但我还没有设法摆脱这种跳跃。
在提供的示例/ jsfiddle中,错误可以通过以下步骤重现:
这里有一个jsfiddle:https://jsfiddle.net/2kgu8c80/19/
外部图书馆:
HTML:
<head>
<title>My Wooden Puzzles</title>
<script src="https://code.jquery.com/jquery-3.0.0.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script type="text/javascript" src="quicksand/quicksand.min.js">/script>
</head>
<body>
<ul id="pzl_filter">
<li id="filter_hard"><a href="javascript:filter('all');">All</a></li>
<li id="filter_hard"><a href="javascript:filter('hard');">Hard</a></li>
<li id="filter_easy"><a href="javascript:filter('easy');">Easy</a></li>
</ul>
<div id="outer-wrapper">
<ul id="pzl_thumbs" class="pzl_thumbs">
<li id="pzl_main_chess_snake" data-id="chess_snake" class="pzl_d_hard">
<img src="http://www.mywoodenpuzzles.com/data/chess_snake/main_thumb.jpg" class="img_thumbs">
<dl><br><dd>Chass Snake</dd></dl></li>
<li id="pzl_main_triforce_2" data-id="triforce_2" class="pzl_d_easy"><a href="javascript:select_puzzle('triforce_2', 'pieces');"><img src="http://www.mywoodenpuzzles.com/data/triforce_2/main_thumb.jpg" class="img_thumbs">
<dl><br><dd>Triforce 2</dd></dl></a></li>
<li id="pzl_main_three_pieces_cross" data-id="three_pieces_cross" class="pzl_d_hard">
<img src="http://www.mywoodenpuzzles.com/data/three_pieces_cross/main_thumb.jpg" class="img_thumbs">
<dl><br><dd>3 pieces cross</dd></dl></li>
<li id="pzl_main_centrifuge" data-id="centrifuge" class="pzl_d_easy">
<img src="http://www.mywoodenpuzzles.com/data/centrifuge/main_thumb.jpg" class="img_thumbs">
<dl><br><dd>Centrifuge</dd></dl></li>
</ul>
</div>
</body>
CSS
/* Layout & items */
#outer-wrapper {
margin: 5px 20px;
}
.pzl_thumbs li,
.img_thumbs {
background-color: transparent;
display: block;
max-height: 100%;
}
.img_thumbs {
height: 192px;
}
.pzl_thumbs li {
float: left;
height: 215px;
margin: 10px 10px 30px 10px;
}
.pzl_thumbs ul {
float: left;
}
.pzl_thumbs dd {
color: #666666;
font-size: 14px;
text-align: center;
}
的JavaScript
var $list = jQuery("#pzl_thumbs");
var $data = $list.clone();
var $filteredData = null;
function filter(difficulty) {
var sel = ((difficulty!='all')? 'li.pzl_d_' + difficulty : 'li') ;
$filteredData = $data.find(sel);
$list.quicksand($filteredData, {
duration: 1800,
adjustHeight: false,
});
}
答案 0 :(得分:1)
问题是max-height: 100%;
的{{1}}。
您需要将其删除,并让.pzl_thumbs li
元素根据其内容自由调整大小。
因此,请修改:
li
对此:
.pzl_thumbs li,
.img_thumbs {
background-color: transparent;
display: block;
max-height: 100%;
}
如果.pzl_thumbs li,
.img_thumbs {
background-color: transparent;
display: block;
}
需要max-height: 100%;
,请将其移到那里:
.img_thumbs