【问题标题】:Css Angular 2 material components for dart. How do I center a glyph?用于飞镖的 Css Angular 2 材质组件。如何使字形居中?
【发布时间】:2017-05-15 06:55:00
【问题描述】:

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 中使用了一个 flexbox -> 显示:inline-flex

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

text-align: center

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

display:block;
margin:auto;

【问题讨论】:

  • &lt;glyph class="center" [icon]="'star'" &gt;&lt;/glyph&gt; 放在div 中并给出一个中心类。例如。 &lt;div class="centerText"&gt;&lt;glyph class="center" [icon]="'star'" &gt;&lt;/glyph&gt;&lt;/div&gt;。如果不起作用,则需要 plunkr 来玩它。

标签: html css angular dart angular2-material


【解决方案1】:

这符合 micronyks 的建议:

<div class="border">
    <div class="centerText">
        <glyph [icon]="'star'" ></glyph>
    </div>
    <div class="centerText">
        This Is Text that is centered.
    </div>
</div>

【讨论】:

    猜你喜欢
    • 2019-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-19
    • 2016-11-10
    • 2018-11-07
    • 1970-01-01
    • 2018-08-04
    相关资源
    最近更新 更多