2016-10-10 82 views
0

我在我的Rails項目中成功設置了PhotoswipeJustified Gallery。他們兩人都很好地工作,但我很難讓他們一起工作。Photoswipe with Justified Gallery

我目前(默認)設置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; 
} 

我一直在玩這個存在了相當一段時間,但我不能做這項工作。另外,我還沒有在網上找到一個好例子。

任何人以前做過或知道如何解決它?

回答

0

我設法通過解決這個確切的問題:

selector: 'a, figure:not(.spinner)' 
在選項

,並通過與figure替換的CSS所有div選擇。所以

.justified-gallery > div > img, 

將成爲:

.justified-gallery > figure > img, 
相關問題