2011-04-06 27 views
0

兩個箭頭我想用CSS只我如何在CSS

實例創建一個箭頭就可以看到http://jsfiddle.net/b9Yfc/

<div id="arrow"><div id="arrow-inner"></div></div> 

我想arrow-inner會的地方變成arrow和結果應該像

enter image description here

如何實現我的目標?

+1

您使用的是相同的ID兩次在您的示例如下。注意不要在你的真實生活版本中這樣做,而應該使用類。 – RoToRa 2011-04-06 11:49:55

+0

@RoToRa是的..將使用真正的網站上的類:)謝謝 – haha 2011-04-06 11:52:33

回答

5

播放與position性質

#arrow添加position: relative;

而且在#arrow-inner添加position: absolute; top:-16px; left:-15px;

而且normaly它的作品。見我http://jsfiddle.net/DoubleYo/cAGWa/

+0

謝謝! @DoubleYo喲!呦!真棒! – haha 2011-04-06 11:58:08

2
#arrow { 
    position: relative; 
    background: // the larger image 
    width: // width of larger image 
    height: // height of larger image 
} 
#arrow-inner { 
    position: absolute; 
    background: // the smaller image 
    width: // the width of smaller image 
    height: // the height of smaller image 
    top: // the offset from the top of the larger image e.g. 2px 
    left: // the offset from the left of the larger image e.g. 5px 
} 
0

,你可以使用你的造型

#arrow { 
    position: relative; 
    background: url('url of the bigger image'); 

} 
#arrow-inner { 
    position: absolute; 
    background: url('url of the smaller image'); 
    top: ;//dimmension in px for the vertical top displacement 
    left: ;//dimmension in px for the vertical left displacement 
    z-index:; dimmension in px for the z displacement though not neccessary 
}