简体   繁体   English

所有元素的同位素边界

[英]Isotope border around all elements

I am using Isotope j Query plugin (Using masonry layout) to show images in my gallery... What i am trying to achieve is a border around all edges of the elements but not in between images.. so the border should only be on the outside and not in between images.... 我正在使用Isotope j Query插件(使用砌体布局)在我的画廊中显示图像...我想要实现的是在元素的所有边缘周围形成边框,而不是在图像之间..因此,边框应仅在外面,而不是在图像之间。

Example of border 边框示例

I have no problem that the border will break between images so that's not an issue :) 我没有问题,图像之间的边框会破裂,所以这不是问题:)

I also need to consider that the user can filter the images so the border should dynamically adapt itself to the number of element and the way they are laid out on the screen. 我还需要考虑到用户可以过滤图像,因此边框应该动态地适应元素的数量以及它们在屏幕上的布置方式。

Thanks all for your time. 感谢您的宝贵时间。

This is the code i use 这是我使用的代码

<div class="project">
    <div class="projects">
        <img src="path/to/image.jpg />
    </div>
    <div class="projects">
        <img src="path/to/image.jpg />
    </div>
    <div class="projects">
        <img src="path/to/image.jpg />
    </div>
</div>

And i run the isotope plugin: 然后我运行同位素插件:

$('.projects').isotope({
    itemSelector: '.project',
    originLeft: false,
    layoutMode: 'packery',
    packery: {
        gutter: 20
    }
});

The isotope itself works great.. 同位素本身很好用。

I Tried styling with psuedos (first, nth etc...) but it didn't work well because the size of the images varies.... 我尝试了psuedos的样式(第一个,第n个,等等),但是效果不佳,因为图像的大小各不相同。

I thought about scanning the images and trying to figure out whether or not there is an item bordering it and setting proper style.. but i'm hoping to avoid this as this task can be very tedious... and I'm lazy ;) 我考虑过扫描图像,并试图找出是否有一个项目与之毗邻并设置适当的样式。.但我希望避免这样做,因为此任务可能非常繁琐……而且我很懒惰; )

I don't think there's an existing method or simple CSS solution to what you're trying to accomplish. 我不认为您要完成的工作没有现有的方法或简单的CSS解决方案。 It looks like Isotope positions each of the elements absolutely and maintains their position/coordinates behind the scenes; 同位素似乎完全定位了每个元素,并在幕后保持了它们的位置/坐标。 shimming the parent container open to a calculated height on the fly. 迅速将父容器打开到计算出的高度。

You might be able to use Isotope's .getfiltereditemelements() and loop through the resulting Array , comparing the width, height, and x/y coordinates to the dimensions of the parent to get an idea as to whether that element is an "edge" element — and whether it is likely a top-row or bottom-row element. 您可能可以使用Isotope的.getfiltereditemelements()并循环遍历所得的Array ,将宽度,高度和x / y坐标与父级的尺寸进行比较,以了解该元素是否为“ edge”元素—以及它可能是顶行还是底行元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM