html - 文本未在我的 li 中居中

标签 html css 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;
        }
    }
}

关于什么可能迫使斯蒂芬马斯顿不居中有任何想法吗?

最佳答案

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

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

关于html - 文本未在我的 li 中居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18519591/

相关文章:

html - Bootstrap 分页中 ul 内的垂直居中跨度

css - 使用 css 更改颜色 svg 文件

html - 如何获取子标题和表格内联?

html - 固定底部导航栏 - 如何让链接以全尺寸展开并负责(使用 %?) navbar-justified 不会工作

css - 更改 <video> 的宽度时,高度没有影响

jquery - 仅在顶级 <li> 中查找文本并应用类

javascript - 从数据库中提取数据并显示在排行榜中

html - 在 django bootstrap 中缩小文本输入字段的大小

flutter - 如何在列中对齐小部件?

javascript - Twitter Bootstrap 3 响应式菜单不起作用