本文介绍了将文本和容器居中放置在圆圈内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这里有一个Bootply:
I have a Bootply here: http://www.bootply.com/XLGE6Vpjov
我需要将3个圆圈居中放置在容器中,然后将其中的文本水平和垂直居中放置。
I need the 3 circles centered in there containers and then I need the text inside to be centered horizontally and verticaly.
如何使文本垂直居中?
我知道 border-radius
在IE8中不起作用,但是我不介意那里是一个正方形。
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;
}
推荐答案
您可以尝试类似的方法
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>
这篇关于将文本和容器居中放置在圆圈内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!