0

HTML:

<div class="border">
    <glyph  class="center" [icon]="'star'" ></glyph>

    <div class="centerText">
        This Is Text that is centered.
    </div>
</div>

CSS:

.centerText{
    text-align: center;

}

.border{
    border: solid black;
    width: 80px;
}

.center{
    margin-left: 50%;
}

结果:

在此处输入图像描述

我正在尝试将来自https://github.com/dart-lang/angular2_components的字形图标居中

如何使字形居中?

https://github.com/dart-lang/angular2_components/blob/master/lib/src/components/glyph/glyph.scss.css中,代码在 css -> display: inline-flex 中使用了一个 flexbox

左边距有点居中,但当宽度更小时看起来很糟糕。有些事情不起作用:

text-align: center

align-items: center;
justify-content: center;

display:block;
margin:auto;
4

1 回答 1

0

这适用于 micronyks 的建议:

<div class="border">
    <div class="centerText">
        <glyph [icon]="'star'" ></glyph>
    </div>
    <div class="centerText">
        This Is Text that is centered.
    </div>
</div>
于 2016-12-31T04:37:36.090 回答