如何制作带有标签的圆形图像?

mor*_*now 5 css jquery

我怎样才能制作出这样的图像,其中有一个标签。

谢谢。

在此输入图像描述

我已经尝试过使用此 css 使图像变圆,但我无法制作像提供的图像这样的标签。

.img-circle {
    border-radius: 50%;
    width: 25%;
    height: 25%;
    position: relative;
    display: inline-block;
    overflow: hidden;
    vertical-align: middle;
}

<img src=".." class="img-circle" />
Run Code Online (Sandbox Code Playgroud)

Nen*_*car 6

您可以在 inside 中使用一个元素img并添加:after伪元素,也可以使用 image 作为background

.el {
  border-radius: 50%;
  width: 100px;
  height: 100px;
  position: relative;
  overflow: hidden;
  border: 2px solid red;
}
.el:after {
  content: '1';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 30px;
  background: red;
  text-align: center;
  line-height: 30px;
  color: white;
}
Run Code Online (Sandbox Code Playgroud)
<div class="el">
  <img src="http://placehold.it/100x100">
</div>
Run Code Online (Sandbox Code Playgroud)

  • 您可以通过使用诸如 data-label 之类的属性来改进这一点,然后使用 **attr() css 函数**设置内容,这将允许用户定义标记中的文本。[**演示**](https://jsfiddle.net/rickyruizm/dec6cdrc/) (3认同)