【发布时间】:2016-11-24 06:09:46
【问题描述】:
<span class="glyphicon glyphicon-chevron-down" aria-hidden="true" style="align:center"></span>
我可以看到图标,但它在左侧。我尝试过 text-align 和 aligh="center" 但似乎没有任何效果
【问题讨论】:
<span class="glyphicon glyphicon-chevron-down" aria-hidden="true" style="align:center"></span>
我可以看到图标,但它在左侧。我尝试过 text-align 和 aligh="center" 但似乎没有任何效果
【问题讨论】:
用容器包裹 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>
【讨论】:
span,这是一个内联元素,所以你要么添加display:block 或使用块级元素,如div,就像@Daerik 在他的示例中所做的那样......再次,所有这些都在my answer given to the other question 中得到了很好的解释......