0

I have a <div> that contains three <div>s. In each of those <div> elements is a <p> element with text and 2 nested elements to make a radial progress bar. What I need is to put the text in the middle of the circles, and do it responsively using pure CSS. I need something like this:

Wanted result

The code has flaws, like that <p> inside of a <span> but I am fixing it in the new version with the help you guys provide.

.radius-container div {
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
}

.radius-container div:first-child {
  margin-right: 1%;
}

.radius {
  padding-top: 11em;
  height: 30em;
  text-align: center;
  border: 1px solid #858280;
  display: block;
  border-radius: 50%;
  width: 100%;
}

.radius3 {
  position: relative;
  padding-top: 10%;
  height: 15em;
  width: 50%;
  text-align: center;
  border: 1px solid #858280;
  border-left: 0;
  border-bottom: 0;
  border-top-right-radius: 100%;
  display: block;
  margin-left: 15em;
}

.radius3 p {
  position: absolute;
  right: 50%;
  top: 65%;
}
<div class="radius-container">
  <div><span class="radius"><p>SERBIAN<br>100%</p></span></div>
  <div><span class="radius"><p>ENGLISH<br>100%</p></span></div>
  <div><span class="radius3"><p>GERMAN<br>25%</p></span></div>
</div>

See also this jsFiddle

Penguin9
  • 481
  • 13
  • 23

3 Answers3

0

After researching for long time for this issue, I found an generic solution which solves this kind of requeriments. I am proud of it, simple and elegant :)

.center-element{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

Hoping it helps, any doubt let me know. Cheers mate :)

Kenzo_Gilead
  • 2,187
  • 9
  • 35
  • 60
0

You can make a div with a border-radius to 50%. After, you can use the flex display to center verticaly and horizontaly.

html

div {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
}
div div {
  display: inline-flex;
  flex-direction: column;
  width: 31%;
  margin: 1%;
  border-radius: 50%;
  border: 1px solid #999;
  align-items: center;
  justify-content: center;
}
div div span {
  text-align: center;
  color: #999;
}
<div>
  <div><span>Serbian</span><span>100%</span>
  </div>
  <div><span>Serbian</span><span>50%</span>
  </div>
  <div><span>Serbian</span><span>25%</span>
  </div>
</div>
G-Cyrillus
  • 101,410
  • 14
  • 105
  • 129
Fridez Lucas
  • 33
  • 1
  • 8
0

This code might help you.

 .innerDiv { 
  height: 100px;
  width: 100px;
  display: table-cell;
  text-align: center;
  vertical-align: middle;
  border-radius: 50%;
  }
shubham agrawal
  • 3,435
  • 6
  • 20
  • 31