响应圈子基于它的内容

Igo*_*gor 6 css geometry css3 responsive-design css-shapes

我有这个例子JSFIDDLE包含一个圆圈,但我很难根据它的内容使其响应,在上面的例子中,当内容很长时,它会溢出圆圈.

.cd-single-point {
    margin:50px;
  position: absolute;
  border-radius: 50%;
}

.cd-single-point > a {
  position: relative;
  text-align:center;
  padding:2px;
  text-decoration: none;
  z-index: 2;
  display: block;
  width: 20px;
  height: 20px;
  border-radius: inherit;
  background: #d95353;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  -webkit-transition: background-color 0.2s;
  -moz-transition: background-color 0.2s;
  transition: background-color 0.2s;
}

.cd-single-point::after {
  /* this is used to create the pulse animation */
  content: '';
  position: absolute;
  z-index: 1;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  border-radius: inherit;
  background-color: transparent;
  -webkit-animation: cd-pulse 2s infinite;
  -moz-animation: cd-pulse 2s infinite;
  animation: cd-pulse 2s infinite;
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能用css实现这个目标?

web*_*iki 4

您可以在伪元素上使用填充技术来保持圆圈的纵横比并使其根据其内容进行响应:

演示版

HTML:

<div class="wrap">
    <div class="in">+46546546</div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

.wrap{
    color: #fff;
    position:relative;
    display:inline-block;
}
.in{
    padding:60% 10%;
    margin-top:-0.6em;
}
.in:after{
    content:'';
    position:absolute;
    top:0; left:0;
    width:120%;
    padding-bottom:120%;
    background-color:#D95353;
    border-radius:50%;
    z-index:-1;
}
Run Code Online (Sandbox Code Playgroud)