我成功地建立了Photoswipe也Justified Gallery在我的Rails项目。他们两人的工作很单纯漂亮,但我有麻烦让他们一起工作。
我目前(默认)设置Photoswipe需要一个标记层次结构如下:
<figure>
<a href="...>
<img src=".../>
</a>
正当画廊默认配置来识别容器与任意数量<a>
标签与内像这样的嵌套<img>
标签:
<div id="mygallery" >
<a href="...>
<img src=".../>
</a>
<a href="...>
<img src=".../>
</a>
<!-- other images... -->
</div>
所以,我需要有对齐库承认<figure>
标签。在他们的文档,它说,你只需要添加以下选项:
selector: 'figure, div:not(.spinner)'
这部分似乎做工精细,但它也提到,有必要延长CSS规则,这就是我坚持。我预计在前面加上全部或部分> a
选择了> figure
选择应该做的工作,但没有。这些都是附带对齐库中的规则:
.justified-gallery {
width: 100%;
position: relative;
overflow: hidden;
}
.justified-gallery > a,
.justified-gallery > div {
position: absolute;
display: inline-block;
overflow: hidden;
opacity: 0;
filter: alpha(opacity=0);
/* IE8 or Earlier */
}
.justified-gallery > a > img,
.justified-gallery > div > img,
.justified-gallery > a > a > img,
.justified-gallery > div > a > img {
position: absolute;
top: 50%;
left: 50%;
margin: 0;
padding: 0;
border: none;
}
.justified-gallery > a > .caption,
.justified-gallery > div > .caption {
display: none;
position: absolute;
bottom: 0;
padding: 5px;
background-color: #000000;
left: 0;
right: 0;
margin: 0;
color: white;
font-size: 12px;
font-weight: 300;
font-family: sans-serif;
}
.justified-gallery > a > .caption.caption-visible,
.justified-gallery > div > .caption.caption-visible {
display: initial;
opacity: 0.7;
filter: "alpha(opacity=70)";
/* IE8 or Earlier */
-webkit-animation: justified-gallery-show-caption-animation 500ms 0 ease;
-moz-animation: justified-gallery-show-caption-animation 500ms 0 ease;
-ms-animation: justified-gallery-show-caption-animation 500ms 0 ease;
}
.justified-gallery > .entry-visible {
opacity: 1.0;
filter: alpha(opacity=100);
/* IE8 or Earlier */
-webkit-animation: justified-gallery-show-entry-animation 500ms 0 ease;
-moz-animation: justified-gallery-show-entry-animation 500ms 0 ease;
-ms-animation: justified-gallery-show-entry-animation 500ms 0 ease;
}
.justified-gallery > .jg-filtered {
display: none;
}
.justified-gallery > .spinner {
position: absolute;
bottom: 0;
margin-left: -24px;
padding: 10px 0 10px 0;
left: 50%;
opacity: initial;
filter: initial;
overflow: initial;
}
.justified-gallery > .spinner > span {
display: inline-block;
opacity: 0;
filter: alpha(opacity=0);
/* IE8 or Earlier */
width: 8px;
height: 8px;
margin: 0 4px 0 4px;
background-color: #000;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
border-bottom-left-radius: 6px;
}
我一直在玩弄这个相当长的一段时间,但我不能做这项工作。此外,我还没有能够在网络上找到一个很好的例子。
任何人做过或知道如何解决呢?
我设法通过解决这个确切的问题:
selector: 'a, figure:not(.spinner)'
在选项,并通过与div
替换的CSS所有figure
选择。所以
.justified-gallery > div > img,
会成为:
.justified-gallery > figure > img,
使用对齐库v3.7.0和PhotoSwipe v4.1.3一个只需要通过替换默认的选择
'figure, > div:not(.spinner)'
因此,对于<div id="mygallery">
得到:
$('#mygallery').justifiedGallery({
selector: 'figure, > div:not(.spinner)'
}).on('jg.complete', function () {
initPhotoSwipeFromDOM('#mygallery');
});