7

I have a Bootply here: http://www.bootply.com/XLGE6Vpjov

I need the 3 circles centered in there containers and then I need the text inside to be centered horizontally and verticaly.

How can I center the text vertically?

I know the border-radius won't work in IE8 but I don't mind it being a square there.

        <div class="container">
            <div class="row">

                <div class="col-md-4 block text-center">
                    <p class="circle">Some Text here Some text here Some text here Some text here</p>
                </div>

                <div class="col-md-4 block">
                    <p class="circle">Some Text here</p>
                </div>

                <div class="col-md-4 block">
                    <p class="circle">Some More Text here</p>
                </div>

            </div>
        </div>


        .block{
            border: 1px solid red;
            text-align: center;
            vertical-align: middle;
        }
        .circle{
            background: red;
            border-radius: 200px;
            color: white;
            height: 200px;
            font-weight: bold;
            width: 200px;
        }
ttmt
  • 5,822
  • 27
  • 106
  • 158

4 Answers4

22

You can try something like this http://jsfiddle.net/6cygbd37/1/

See working example below :

/*--CSS--*/
 .block {
    border: 1px solid red;
    text-align: center;
    vertical-align: middle;
}
.circle {
    background: red;
    border-radius: 200px;
    color: white;
    height: 200px;
    font-weight: bold;
    width: 200px;
    display: table;
    margin: 20px auto;
}
.circle p {
    vertical-align: middle;
    display: table-cell;
}
<!--HTML-->
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet">
 <div class="container">
    <div class="row">
        <div class="col-md-4 block">
            <div class="circle">
                <p>Some Text here Some text here</p>
            </div>
        </div>
        <div class="col-md-4 block">
            <div class="circle">
                <p>Some Text here</p>
            </div>
        </div>
        <div class="col-md-4 block">
            <div class="circle">
                <p>Some More Text here</p>
            </div>
        </div>
    </div>
</div>
Sangrai
  • 687
  • 1
  • 6
  • 19
Bojan Petkovski
  • 6,835
  • 1
  • 25
  • 34
2

Your Answer is ...

.block{
            border: 1px solid red;
            text-align: center;
            vertical-align: middle;
        }
        .circle{
            background: red;
            border-radius: 200px;
            color: white;
            height: 200px;
            font-weight: bold;
            width: 200px;
        }
  .circle span{
   display: table-cell;
   padding-top:40%;
  }
<div class="container">
 <div class="row">
      
    <div class="col-md-4 block">
         <p class="circle" align="center"><span>Some Text here Some text here Some text here</span></p>
     </div>
       
       <div class="col-md-4 block">
        <p class="circle" align="center"><span>Some Text here Some text here Some text here</span></p>
     </div>
      
       <div class="col-md-4 block">
        <p class="circle" align="center"><span> Some text here</span></p>
     </div>
  
   </div>
</div>
eli
  • 8,571
  • 4
  • 30
  • 40
Avinash Antala
  • 641
  • 5
  • 10
1

One solution could be add line-height:200px; to your .circle class So the line Height will be the same height as the circle itself.

.circle {
  /* your code */
  line-height:200px;
}
1

You can use display: table-cell instead of inline-block

Example

.circle {
  display: table-cell;
}
Colin Bacon
  • 15,436
  • 7
  • 52
  • 72