圆形div气球
Circle div balloon
这是我目前的 css 图像圈气球
.circle-image{
width: 64px;
height: 64px;
border-radius: 50%;
background-size: contain;
background-position: center;
background-image: url("/assets/img/dashboard/img-stdn.png");
display: block;
}
div 输出如下:
我怎么才能把div镶边变成这样呢?
假设 div 中的图像:
如果您正在寻找箭头,这就是您需要添加的内容。
http://jsfiddle.net/c3Love5c/1/
.circle-image{
width: 64px;
height: 64px;
border-radius: 50%;
background-size: cover;
background-position: center;
background-image: url("http://i.stack.imgur.com/lCp2t.png");
display: block;
border:3px solid purple;
position:relative;
}
.circle-image:before{
content:'';
display:block;
border:10px solid transparent;
border-top-color:purple;
position:absolute;
right:-5px;
top:5px;
transform:rotate(15deg);
-moz-transform:rotate(15deg);
-webkit-transform:rotate(15deg);
-ms-transform:rotate(15deg);
-o-transform:rotate(15deg);
}
您可以使用伪元素来创建语音气泡三角形,如下面的演示所示。
这通过在正方形上使用 skew
并将其放置 absolute
ly 在 relative
ly 定位的容器元素中来实现。
或者,如果您能够使用 background-image
而不是图像标签,则可以使用单个元素来实现。
.circ {
height: 100px;
width: 100px;
border-radius: 50%;
bordeR: 5px solid tomato;
position: relative;
}
.circ img {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
border-radius: 50%;
}
.circ:before{
content:"";
position:absolute;
top:10%;
right:0;
height:20px;
width:20px;
background:tomato;
transform:skewX(55deg) skewY(10deg);
}
<div class="circ">
<img src="http://i.stack.imgur.com/lCp2t.png" />
</div>
有关生成三角形的更多信息,您可能会发现 关于如何实现此三角形的非常有用的演示。
背景图片
通过使用背景图像,您可以仅使用一个元素来实现。
.circ {
position: relative;
height: 100px;
width: 100px;
border-radius: 50%;
border: 5px solid tomato;
background:url(http://i.stack.imgur.com/lCp2t.png);
background-size:100% 100%;
}
.circ:before{
content:"";
position:absolute;
top:10%;
right:0;
height:20px;
width:20px;
background:tomato;
transform:skewX(55deg) skewY(10deg);
z-index:-1;
}
<div class="circ"></div>
这是我目前的 css 图像圈气球
.circle-image{
width: 64px;
height: 64px;
border-radius: 50%;
background-size: contain;
background-position: center;
background-image: url("/assets/img/dashboard/img-stdn.png");
display: block;
}
div 输出如下:
我怎么才能把div镶边变成这样呢?
假设 div 中的图像:
如果您正在寻找箭头,这就是您需要添加的内容。
http://jsfiddle.net/c3Love5c/1/
.circle-image{
width: 64px;
height: 64px;
border-radius: 50%;
background-size: cover;
background-position: center;
background-image: url("http://i.stack.imgur.com/lCp2t.png");
display: block;
border:3px solid purple;
position:relative;
}
.circle-image:before{
content:'';
display:block;
border:10px solid transparent;
border-top-color:purple;
position:absolute;
right:-5px;
top:5px;
transform:rotate(15deg);
-moz-transform:rotate(15deg);
-webkit-transform:rotate(15deg);
-ms-transform:rotate(15deg);
-o-transform:rotate(15deg);
}
您可以使用伪元素来创建语音气泡三角形,如下面的演示所示。
这通过在正方形上使用 skew
并将其放置 absolute
ly 在 relative
ly 定位的容器元素中来实现。
或者,如果您能够使用 background-image
而不是图像标签,则可以使用单个元素来实现。
.circ {
height: 100px;
width: 100px;
border-radius: 50%;
bordeR: 5px solid tomato;
position: relative;
}
.circ img {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
border-radius: 50%;
}
.circ:before{
content:"";
position:absolute;
top:10%;
right:0;
height:20px;
width:20px;
background:tomato;
transform:skewX(55deg) skewY(10deg);
}
<div class="circ">
<img src="http://i.stack.imgur.com/lCp2t.png" />
</div>
有关生成三角形的更多信息,您可能会发现
背景图片
通过使用背景图像,您可以仅使用一个元素来实现。
.circ {
position: relative;
height: 100px;
width: 100px;
border-radius: 50%;
border: 5px solid tomato;
background:url(http://i.stack.imgur.com/lCp2t.png);
background-size:100% 100%;
}
.circ:before{
content:"";
position:absolute;
top:10%;
right:0;
height:20px;
width:20px;
background:tomato;
transform:skewX(55deg) skewY(10deg);
z-index:-1;
}
<div class="circ"></div>