对齐圆形边框

时间:2015-09-16 18:53:39

标签: html css css3 twitter-bootstrap-3 css-shapes

我无法将圆形边框与其上方的文字对齐,并使文本在圆圈内居中。当我在width: 80px;课程中注释掉.oval时,它似乎已对齐,但圈子会被扭曲

enter image description here

<div class="container body-content">
    <div class="row tab-content">
        <div class="jumbotron">
            <h1>Welcome, Admin</h1>
            <p class="lead">Please select one of the tabs above to begin</p>
        </div>
        <div class="row adminrow">
            <div class="col-xs-2 col-xs-offset-1">
                <h4>Total Users</h4>
                <div class="oval">
                    <h4>100</h4>
                </div>
            </div>
            <div class="col-xs-2">
                <h4>Unauthorized Users</h4>
                <div class="oval">
                    <h4>25</h4>
                </div>
            </div>
            <div class="col-xs-2">
                <h4>Total Games</h4>
                <div class="oval">
                    <h4>0</h4>
                </div>
            </div>
            <div class="col-xs-2">
                <h4>Games Played</h4>
                <div class="oval">
                    <h4>80</h4>
                </div>
            </div>
            <div class="col-xs-2">
                <h4>Investigator Groups</h4>
                <div class="oval">
                    <h4>2</h4>
                </div>
            </div>
        </div>
    </div>
</div>

我的CSS类如下

.tab-content {
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    padding: 30px;
}

.jumbotron {
    text-align: center;
}

.adminrow {
    text-align: center;
}

.oval {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #000000;
    color: white;
    text-align: center;
}

2 个答案:

答案 0 :(得分:1)

添加这个会做你想要的吗?

.oval {
    line-height: 80px;
}

答案 1 :(得分:1)

您只需要更改圈子的display属性:

{
    border-radius: 50%;
    display: block;
    width: 80px;
    line-height: 80px;
    text-align: center;
    // other properties
}