我想做一个像水平标签的东西:但是有一个条件,应该是一个独特的div.可能有画布是可能的,但我喜欢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;
}
Run Code Online (Sandbox Code Playgroud)

您可以使用一些边框黑客,定位和:在psudo-element之前完成此操作.
#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;
}
Run Code Online (Sandbox Code Playgroud)