2014-01-26 17 views
0

所以我在我的CSS文件添加多個CSS矩形組合在一起

#background .icicle#ice1 { 
    left: 24%; 
    top: 0%; 
    width: 2%; 
    height: 8%; 
} 

#background .icicle#ice2 { 
    left: 26%; 
    top: 0%; 
    width: 2%; 
    height: 16%; 
} 

#background .icicle#ice3 { 
    left: 28%; 
    top: 0%; 
    width: 2%; 
    height: 4%; 
} 

3個矩形和我打電話給他們,像這樣

<div id="background"> 
     <div class="icicle" id="ice1"></div> 
     <div class="icicle" id="ice2"></div> 
     <div class="icicle" id="ice3"></div> 
    </div> 

我想知道如何添加ice1,2 ,3個在一起,因爲如果我把它們放在一起,最後一個矩形將替換前一個矩形。

#background .icicle#ice1 { 
    left: 24%; 
    top: 0%; 
    width: 2%; 
    height: 8%; 

    left: 26%; 
    top: 0%; 
    width: 2%; 
    height: 16%; 

    /* This one would only be displayed */ 
    left: 28%; 
    top: 0%; 
    width: 2%; 
    height: 4%; 
} 
+0

對不起,我沒有得到它。你能解釋一下你的意思嗎? –

+0

所以你需要一個大矩形而不是3個單獨的矩形? – techfoobar

+0

您是否設置位置:在包裝div和position上的相對位置:absoluteicle類上的絕對位置? – Danield

回答

1

你可以組這三個小片冰柱成一個像這樣的:使用

<div id="background"> 

    <!-- Each Icicle ---> 
    <div class="icicle" id="ice1"> 
     <!-- Pieces that make up each icicle --> 
     <span></span> 
     <span></span> 
     <span></span> 
    </div> 

</div> 

和位置的每個冰柱的ID的

http://jsfiddle.net/samliew/KJKLV/

+0

你有什麼建議嗎? – Exikle

+0

這實際上取決於你想要達到的目標。你是否顯示某種背景?你能簡單地結合圖像嗎?你可以在JSfiddle中重現你的代碼,告訴我們你的冰柱是什麼樣的? –

+0

那麼它的一個github頁面我正在玩,所以這裏是鏈接到實際頁面,如果你想看看它http://exikle.github.io/ – Exikle