2013-03-10 60 views
0

我想在我的DIV之間有一條薄的「陰影」線作爲分隔符。由於我希望陰影線變得更細膩,頂部和底部的陰影更多,因此我創建了3個圖像:中間陰影,頂部陰影和底部陰影。問題:我不知道如何將「頂部陰影」圖像放置在底部(沒有多個DIV)的「中間陰影」和「底部」陰影的頂部。我在安裝完成煙花的圖像,你可以看到和榜樣的影子line.Many TKS的enter image description here陰影線與圖像作爲垂直分隔符btw DIV - 如何放置頂部和底部的圖像?

div#content-center { 
    overflow: hidden; 
    background: khaki; 
    background: transparent url('images/middle_shadow.png') repeat-y top left; 
    padding: 0px 0px 0px 50px; 
} 

回答

1

您可能也有與亞伯做到這一點:before:after psedo-elements。 Read up on them here如果你不熟悉。

#content-center{ 
    background: url('images/shadow_repeat.png') center right repeat-y; 
} 

#content-center:before, 
#content-center:after{ 
    content:''; 
    display:inline-block; 
    position: absolute; 
    background-repeat: none; 

    /*size these to be what you need*/ 
    height:100px; 
    width:100px; 
} 

#content-center:before{ 
    top:0; 
    background-image: url('images/shadow_top.png'); 
} 

#content-center:after{ 
    bottom:0; 
    background-image:url('images/shadow_bottom.png'); 
} 
+0

謝謝 - 我試過,但沒有成功,請參閱jsfiddle:http://jsfiddle.net/Grek/Jcq2D/ – Greg 2013-03-10 21:44:42

+0

這並不意味着是一個完整的解決方案,只是一種讓您開始的方式,因爲您沒有提供任何其他代碼。我更新了小提琴並在CSS中做了一些筆記。 http://jsfiddle.net/Jcq2D/2/ – 2013-03-11 03:33:13

+0

感謝克里斯,效果很好,並且您添加的評論非常有幫助! – Greg 2013-03-11 06:55:40

0

給多背景:

background: url('images/middle_shadow.png') top left, url('images/middle_shadow2.png') center left,url('images/middle_shadow3.png') repeat-y bottom left; 
+0

由於丹,我想你的建議的解決方案,但似乎並不奏效,看到的jsfiddle根據你的建議:http://jsfiddle.net/Grek/tZADk/ – Greg 2013-03-10 21:52:41

相關問題