文字不在我的中心

时间:2013-08-29 19:35:53

标签: html css css3 alignment

Demo link

不确定为什么第二个列表中的文字没有居中。

enter image description here

HTML

<div id="the_target">
    <ul>
        <li>Stephen Marston</li>
        <li>Account Exectutive</li>
        <li>The Company</li>
    </ul>
</div>

SASS:

section {
    #the_requestor {
        margin-top: 40px;
        ul { margin-top: 10px; }
        ul li {
            text-align: center;
            line-height: $px20;
        }
        li:first-child {
            font-family: LatoBold;
            font-size: $px30;
            background: cyan;
        }
    }
    #the_target {
        position: relative;
        margin-top: 40px;
        ul { margin-top: 10px; }
        ul li {
            text-align: center;
            line-height: $px20;
        }
        li:first-child{
            font-family: LatoBold;
            font-size: $px30;
            background: cyan;
        }
    }
}

关于什么可能迫使斯蒂芬马斯顿不在中心的任何想法?

2 个答案:

答案 0 :(得分:5)

#mobile-action-area中存在一个正在干扰的元素。你需要清除这个浮动。有多种方法可以做到这一点。将overflow: hidden添加到#mobile-action-area会修复它。您也可以尝试:

#mobile-action-area:after {
    display: table;
    content: "";
    clear: both;
}

答案 1 :(得分:2)

你需要在#the_target

之前清除浮动
   #the_target {
            position: relative;
            margin-top: 40px;
            clear:both;
    }