html - 用于 Dart 的 Css Angular 2 Material 组件。我如何使字形居中?

标签 html css angular dart angular2-material

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%;
}

结果:

enter image description here

我正在尝试将 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

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

text-align: center

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

display:block;
margin:auto;

最佳答案

这适用于 micronyks 的建议:

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

关于html - 用于 Dart 的 Css Angular 2 Material 组件。我如何使字形居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41405273/

相关文章:

javascript - 如何使相对 Div 可拖动?

javascript - 强制 textarea 和 pre 元素大小相同,并在 IE 中的相同点换行。

angular - 完成for循环后如何完成订阅者?

angular - Kendo Ui Angular2 Grid 分页到第一页

css - Modernizr 在 Chrome 和 FF 中将笔记本电脑报告为触摸设备

Angular 检索数据问题(Cannot read property 'uid' of null)

javascript - 代码在 jsfiddle 中有效,但在浏览器中无效

javascript - JqG​​rid 不通过移动选项卡加载

javascript - 脚本标签——不链接(JS平台游戏)

html - Chrome 18 围绕表单元素呈现伪影