2016-10-15 9 views
0

テキストと画像の間にスペースを入れる方法を考えています。私は単語の間隔、詰め物を含め、これまでに学んだことをすべて試しました。href要素内のimgとtextの間のスペースを増やします(単語の間隔?padding?)

あなたが私が達成したいことをよりよく理解できるように、あなたの写真を見せてください。 example イメージとテキストの間のスペースを増やしたいと考えています。黄色で強調表示されます。 このサンプルコードを使用してどのように達成できますか? Link to CodePen

HTML

<div class="navbar-header"> 
    <div class="container"> 
    <div id="logo"> 
     <a href="#"> 
     Amazing <img src="http://www.clipartkid.com/images/650/image-spiderman-logo-png-spider-man-wiki-wikia-hYo1XM-clipart.png"/> Spiderman 
     </a> 
    </div> 
    </div> 
</div> 

CSS

.navbar-header { 
    border-bottom: 1px solid black; 
    height: 70px; 
    margin-bottom: 0; 
    position: fixed; 
    width: 100%; 
    z-index: 100; 
} 

.container { 
    align-items: center; 
    display: flex; 
    flex-direction: row; 
    height: 100%; 
    width: 100%; 
} 

#logo { 
    align-items: center; 
    margin: auto; 
} 

#logo a { 
    align-items: center; 
    color: black; 
    display: flex; 
    flex-grow: 2; 
    margin: auto; 
    text-decoration: none; 
    word-spacing: 200px; 
} 

#logo img { 
    height: 66px; 
    margin: auto; 
} 
+0

画像の前後にスペースを入れてみましたか? を試したことがありますか?ありがとうございます。 –

+0

いいえ、聞いたことがありません。しかし、私はそれが動作して参照してください。私はスペースの幅をワードスペースでコントロールすることができます。 – xeho91

答えて

1

私は左/右マージンを与えることが最良の解決策であるべきだと思う。

#logo img { 
    height: 66px; 
    margin: auto 20px; 
} 
1

私はあなたの質問を理解していれば.....私はちょうど約の#logoのIMGに左右のマージンを追加しますあなたが望むスペース

#logo img { 
    height: 66px; 
    margin: auto; 
    /*you would want to change this, so as to not have both declarations, I just dont know how much top and bottom margin you want*/ 
    margin-left: 15px; 
    margin-right: 15px 
} 
関連する問題