【发布时间】:2016-10-10 13:44:28
【问题描述】:
我在我的 Rails 项目中成功设置了 Photoswipe 和 Justified Gallery。他们两个单独工作都很好,但我很难让他们一起工作。
在我当前的(默认)设置中,Photoswipe 期望标签层次结构如下:
<figure>
<a href="...>
<img src=".../>
</a>
Justified Gallery 默认配置为识别具有任意数量 <a> 标记的容器,其中嵌套了 <img> 标记,如下所示:
<div id="mygallery" >
<a href="...>
<img src=".../>
</a>
<a href="...>
<img src=".../>
</a>
<!-- other images... -->
</div>
所以我需要让 Justified Gallery 识别 <figure> 标签。在他们的文档中,它说您只需添加以下选项:
selector: 'figure, div:not(.spinner)'
这部分似乎工作正常,但也提到有必要扩展 CSS 规则,这就是我卡住的地方。我希望在所有或部分> a 选择器前面加上> figure 选择器应该可以完成这项工作,但不是。以下是 Justified Gallery 附带的规则:
.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;
}
我已经玩了很长时间了,但我无法完成这项工作。我也无法在网上找到一个很好的例子。
有没有人做过这个或者知道怎么解决?
【问题讨论】:
标签: css ruby-on-rails image-gallery photoswipe