jquery 可排序、浮动和清除
所以我在这里有一个我想要做的快速模型 - http://antimac。 meloncreative.co.uk/labs/nth.php
实时版本是使用 div 内的缩略图完成的,这些缩略图具有不同的宽高比。因此宽度始终为 100px,但高度可以是任何值(或多或少)。
无论如何,正因为如此,并且使用浮动,有时它们不能很好地融入一条线上的 5 条线上,有些低于其他线,所以它们或多或少都在自己的线上,这使得它看起来很混乱。
那么...在排序和更新时如何做到这一点,clears总是能很好地使每行5个div?目前我正在做的事情
$('#reorder div.x:nth-child(5n)').addClass('clear green');
...并没有像我希望的那样工作
编辑:所以我认为问题出在 (5n) 部分,就像当我将第 1 项拖动到 5 和6、在拖动过程中,第一行缺少 2 个块,然后当我放下它时,第一行缺少 1 个块。这可能与我所拖动的克隆仍然在那里影响结果、想法有关?
So I have a quick mockup here of what I am trying to do - http://antimac.meloncreative.co.uk/labs/nth.php
The live version is done using thumbnails inside the divs, and these thumbnails are of various aspect ratios. So the width is always 100px, but the height can be whatever (more or less).
Anyways, because of this, and using float, sometimes they dont nicely fit into 5 on a line, with some going below others so they are more or less on their own line, which makes it look a mess.
So... how do I make it when sorting, and when updated, the clears will always nicely make 5 divs per row? Currently the bit where I am doing
$('#reorder div.x:nth-child(5n)').addClass('clear green');
... isnt working as I'd hoped
Edit: So I think the problem lies in the (5n) part, as when I drag say item 1, between 5 and 6, during the drag there are 2 blocks missing from the first row, then when I drop it, there is 1 missing from the first row. This possibly has something to do with the clone of the one I am dragging still being there slewing the results, ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为这还可以。只需确保在 x div 重新排序后添加绿色类即可。看看这个小提琴。 :eq 无法识别 n,请使用 :nth-child。
I think this is okay. just make sure adding class green after x divs have reordered. Look this fiddle. :eq doesn't recognize n, use :nth-child.
所以答案似乎是
占位符和助手仍然存在问题,因为被拖动的内容仍然存在。
So the answer seemed to be
It was having issues with placeholders and also the helper that was still in place from what was being dragged around.