2016-12-31 7 views
0

HTML:Cssダーツの角度2の素材コンポーネント。グリフを中央に揃えるにはどうすればいいですか?

<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

からグリフのアイコンを中心にしようとしています

enter image description here

グリフ?マージン左は一種のそれを中心にされたインラインフレックス

が、幅が小さい場合には、悪いなります>ディスプレイ -

https://github.com/dart-lang/angular2_components/blob/master/lib/src/components/glyph/glyph.scss.cssでコードがCSSのフレキシボックスを使用しています。

text-align: center 

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

とmicronyks提案ごとに動作します。この

display:block; 
margin:auto; 
+0

プット '<グリフクラス「=動作しませんでした事があります。 center "[icon] =" 'star' ">'の中の 'div'とgセンタークラス。例えば。 '

'もし動作しなければplunkrを持って遊ぶ必要があります。 – micronyks

答えて

0

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

嬉しいです! – micronyks

関連する問題