2014-12-02 40 views
0

我是新來的CSS和HTML,我想知道是否有一種方法,我可以使用相同的CSS,但在每個六邊形內有不同的圖像。我想使用多個圖像來代替'http://placekitten.com/240/240',而不需要複製/編寫太多的代碼。將多個圖像添加到此六角形類

退房小提琴下面來看看我的意思:

<div class="pfhex1"> 
    <div class="hexagon hexagon2"> 
    <div class="hexagon-in1"><div class="hexagon-in2"></div> 
    </div></div> 

     <div class="pfhex2"> 
    <div class="hexagon hexagon2"> 
    <div class="hexagon-in1"><div class="hexagon-in2"></div> 
    </div></div> 

http://jsfiddle.net/1v57w6xh/

非常感謝。

+0

與其父變化吧''.pfhex1'堂妹.pfhex2'將它改變 – 2014-12-02 18:10:20

+0

涉及的問題:http://stackoverflow.com/questions/26114920/responsive-grid-of-hexagons-with-img-標籤/ 26116497#26116497 – 2014-12-02 18:28:47

回答

0

您可以創建一個具有不同背景圖像的新類,並將其應用於要更改的div,或使用現有選擇器創建新規則,並將不同的背景圖像應用於該類,如:

.pfhex2 .hexagon.hexagon2 .hexagon-in1 .hexagon-in2 { 
/* different image */ 
} 
+0

非常感謝,我一直在這一整天,這真是令人氣憤。你解決了我的問題。 – 2014-12-02 18:50:51