Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Center text and container inside a circle

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;
        }
like image 392
ttmt Avatar asked Nov 05 '14 10:11

ttmt


2 Answers

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>
like image 148
Bojan Petkovski Avatar answered Oct 27 '22 11:10

Bojan Petkovski


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>
like image 27
Avinash Antala Avatar answered Oct 27 '22 11:10

Avinash Antala