圆圈div气球

Ner*_*ere 4 html css css-shapes

这是我目前的图像圈气球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;
}
Run Code Online (Sandbox Code Playgroud)

div输出如下:

在此输入图像描述

我如何能够与div接壤并变得像这样?

在此输入图像描述

让我们说div里面的图像:

在此输入图像描述

jbu*_*483 6

您可以使用伪元素来创建语音气泡三角形,如下面的演示所示.

这通过skew在正方形上使用,并将其定位absoluterelative定位的容器元素内.

或者,如果您能够使用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);
  }
Run Code Online (Sandbox Code Playgroud)
<div class="circ">
  <img src="http://i.stack.imgur.com/lCp2t.png" />
</div>
Run Code Online (Sandbox Code Playgroud)

有关生成三角形的更多信息,您可能会发现是如何实现此三角形的非常有用的演示.


背景图片

通过使用背景图像,您可以只使用一个元素.

.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;
  }
Run Code Online (Sandbox Code Playgroud)
<div class="circ"></div>
Run Code Online (Sandbox Code Playgroud)