纯 CSS 三角形,带有半透明边框。可能的?
是否可以仅使用 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;
}
Is it possible to draw an arrow that has semi-transparent border around it just using css?
Heres a fiddle of my effort so far:
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这仍然需要一些工作,但总体思路如下:
使用伪元素,将其旋转 45 度并对其应用样式:
这是小提琴: http ://jsfiddle.net/yZ3vB/
这样做的问题是边框重叠,导致边缘变暗。
不过,这可能可以通过添加另一个元素来解决。
更新:是的!给你: http://jsfiddle.net/sJFTT/
更新 2: 你甚至不知道需要那个额外的元素。您可以使用主框中的伪元素:
这是小提琴: http://jsfiddle.net/6v9nV/
更新3:实际上,您可以通过使用两个伪元素 -
before
和来仅使用单个元素来完成所有这些操作,并且无需进行任何转换之后
:这是fiddle: http://jsfiddle.net/95vvr/
PS 不要忘记生产中的供应商前缀!
This still needs some work, but here's the general idea:
Use a pseudo-element, rotate it 45deg and apply the styling to that:
Here's the fiddle: http://jsfiddle.net/yZ3vB/
The problem with this is that the borders overlap, making it darker by the edges.
This could probably be remedied by adding another element though.
Update: Yes! Here you go: http://jsfiddle.net/sJFTT/
Update 2: You don't even need that additional element. You can use the pseudo element from the main box:
Here's the fiddle: http://jsfiddle.net/6v9nV/
Update 3: Actually, you can do all this with just a single element and no transform, by using both pseudo-elements - the
before
and theafter
:Here's the fiddle: http://jsfiddle.net/95vvr/
P.S. Don't forget the vendor prefixes in production!
您需要对图像进行凹口并将该图像绝对放置在右下角。
You need notch image and place that image absolutely at bottom right corner.