2011-11-09 97 views
2

我正在尝试制作类似于水平标签的东西: 但有条件,应该是唯一的div。可能与画布是可能的,但我有喜欢的CSS。使用CSS制作箭头

#msg { 
    border-bottom: 10px solid transparent; 
    border-right: 10px solid red; 
    border-top: 10px solid transparent; 
    height: 0; 
    width: 100px; 
    background-color: rgba(0,0,0,.8);  margin-left:20px; 
} 

enter image description here

demo

+0

看到http://cssarrowplease.com/ –

回答

5

你可以用一些边境黑客,定位做到这一点,和:前psudo元素。

http://jsfiddle.net/VQcyD/

#msg { 
    width:100px; 
    height:40px; 
    background:red; 
    margin-left:40px; 
    position:relative; 

} 
#msg:before { 
    content:""; 
    position:absolute; 
    border-bottom: 20px solid transparent; 
    border-right: 20px solid red; 
    border-top: 20px solid transparent; 
    height: 0px; 
    width: 0px; 
    margin-left:-20px; 
} 
+0

这是伟大的。谢谢 – user947462

+0

@ user947462不客气:)高兴地帮忙。 –