cal*_*ebo 20 css webkit mobile-safari css3
是否可以使用css绘制一个围绕它的半透明边框的箭头?
到目前为止,这是我努力的一个小提琴:http: //jsfiddle.net/calebo/fBW4u/
CSS:
.ui-overlay {
padding-bottom: 10px;
position: relative;
}
.ui-overlay-content {
background: #999;
color: #000;
padding: 8px;
border-radius: 4px;
border: 5px solid rgba(0, 0, 0, 0.2);
background-clip: padding-box;
height: 100px;
width: 200px;
}
.arrow {
border-color: #999 transparent transparent;
border-style: solid;
border-width: 10px 10px 0;
bottom: 5px;
left: 15px;
width: 0;
height: 0;
position: absolute;
overflow: hidden;
}
Run Code Online (Sandbox Code Playgroud)
Jos*_*ber 45
这仍然需要一些工作,但这是一般的想法:
使用伪元素,将其旋转45度并将样式应用于:
.arrow {
bottom: -25px;
left: 30px;
width: 40px;
height: 40px;
position: absolute;
overflow: hidden;
}
.arrow:after {
content: ' ';
display: block;
background: red;
width: 20px;
height: 20px;
transform: rotate(45deg);
position: absolute;
top: -19px;
left: 3px;
background: #999;
border: 5px solid rgba(0, 0, 0, 0.2);
background-clip: padding-box;
}
Run Code Online (Sandbox Code Playgroud)
这是小提琴:http://jsfiddle.net/yZ3vB/
这个问题是边框重叠,使边缘变暗.
这可能可以通过添加另一个元素来解决.
更新:是的!你去了:http://jsfiddle.net/sJFTT/
更新2:您甚至不需要那个额外的元素.您可以使用主框中的伪元素:
.ui-overlay-content:after {
content: ' ';
border-width: 13px;
border-color: #999 transparent transparent;
border-style: solid;
bottom: -10px;
left: 30px;
width: 0;
height: 0;
position: absolute;
}
Run Code Online (Sandbox Code Playgroud)
这是小提琴:http://jsfiddle.net/6v9nV/
更新3:实际上,你可以通过使用两个伪元素来完成所有这一切,只需要一个元素而不需要转换 - before
和after
:
.speech-bubble {
background: #999;
background: linear-gradient(top, #444 0%,#999 100%);
background-clip: padding-box;
border: 5px solid rgba(0, 0, 0, 0.2);
padding: 20px;
width: 200px;
height: 100px;
position: relative;
}
.speech-bubble:before{
content: ' ';
border-color: rgba(0, 0, 0, 0.2) transparent transparent;
border-style: solid;
border-width: 17px;
position: absolute;
bottom: -39px;
left: 16px;
}
.speech-bubble:after{
content: ' ';
border-color: #999 transparent transparent;
border-style: solid;
border-width: 13px;
position: absolute;
bottom: -26px;
left: 20px;
}
Run Code Online (Sandbox Code Playgroud)
这是小提琴:http://jsfiddle.net/95vvr/
PS不要忘记生产中的供应商前缀!