【问题标题】:Text not centering in my li文字不在我的 li 中居中
【发布时间】:2013-08-30 03:48:14
【问题描述】:

Demo link

不知道为什么我在第二个列表中的文本没有居中。

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;
        }
    }
}

你有什么想法可能会迫使斯蒂芬马斯顿不居中吗?

【问题讨论】:

    标签: html css alignment


    【解决方案1】:

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

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

    【讨论】:

    • 或添加“display:inline-block;”到这种风格:“body#mobile-request .container #mobile-action-area”
    • 啊,原来如此!我不得不破解我的#mobile-deny-request,因为由于某种原因按钮太低了。谢谢! :)
    【解决方案2】:

    您需要在#the_target 之前清除浮动

       #the_target {
                position: relative;
                margin-top: 40px;
                clear:both;
        }
    

    【讨论】:

      猜你喜欢
      • 2019-09-27
      • 2017-10-25
      • 2016-01-08
      • 1970-01-01
      • 2014-11-15
      • 2013-08-11
      • 2014-12-12
      • 2015-11-18
      • 2018-01-28
      相关资源
      最近更新 更多