【问题标题】:I can't seem to get the glyph to center align on the page我似乎无法让字形在页面上居中对齐
【发布时间】:2016-11-24 06:09:46
【问题描述】:
<span class="glyphicon glyphicon-chevron-down" aria-hidden="true" style="align:center"></span>

我可以看到图标,但它在左侧。我尝试过 text-align 和 aligh="center" 但似乎没有任何效果

【问题讨论】:

标签: html css


【解决方案1】:

用容器包裹 span 并将其 text-align 设置为居中。

.parent-container { text-align:center; }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="parent-container">
  <span class="glyphicon glyphicon-chevron-down" aria-hidden="true"></span>
</div>

【讨论】:

  • 天啊,非常感谢。我什至尝试将它放在
    中,但至少我在正确的轨道上再次感谢
  • 这样也可以。如果它解决了您的问题,请务必将其标记为已接受的答案。谢谢!
  • 查看我对这个问题的评论:这是重复的......正如my answer on the other question 中所解释的,你的没用,因为你使用的是span,这是一个内联元素,所以你要么添加display:block 或使用块级元素,如div,就像@Daerik 在他的示例中所做的那样......再次,所有这些都在my answer given to the other question 中得到了很好的解释......
猜你喜欢
相关资源
最近更新 更多
热门标签