How do I responsively center text inside of a

前端 未结 3 476
被撕碎了的回忆
被撕碎了的回忆 2020-12-22 11:23

I have a

that contains three
s. In each of those
elements is a

element with

相关标签:
3条回答
  • 2020-12-22 12:03

    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>

    0 讨论(0)
  • 2020-12-22 12:08

    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 :)

    0 讨论(0)
  • 2020-12-22 12:13

    This code might help you.

     .innerDiv { 
      height: 100px;
      width: 100px;
      display: table-cell;
      text-align: center;
      vertical-align: middle;
      border-radius: 50%;
      }
    
    0 讨论(0)
提交回复
热议问题