Centering text vertically and horizontally in a div

前端 未结 1 1606
再見小時候
再見小時候 2021-01-03 11:11

I am using bootstrap and I am attempting to make a Cell that is 100% height and width of its host container.

The title is 30% of that space and the value is 70%. The

相关标签:
1条回答
  • 2021-01-03 11:50

    Making text central is fairly trivial, the easiest approach is as follows. You can check out the jsFiddle too: https://jsfiddle.net/jL9bs0j7/

    .text-container {
      height:200px;
      width:400px;
      border: 1px solid #000;
      text-align: center;
    }
    
    .text-container span {
      display: block;
      position: relative;
      top: 50%;
      transform: translateY(-50%);
    }
    <div class="text-container">
      <span>Hello World</span>
    </div>

    0 讨论(0)
提交回复
热议问题