2017-02-16 5 views
0

次の例では、中央に配置された画像の左端にキャプションを簡単に揃えることはできますか?水平に配置された画像の左にキャプションを配置

現在、表示は次のようになります。

 ____________________ 
    |     | 
    |     | 
    |     | 
    |     | 
    |____________________| 
This is my caption 

私はそれはあなたがこのようにそれを行うことができ、この

____________________ 
|     | 
|     | 
|     | 
|     | 
|____________________| 
This is my caption 

.container{ 
 
    width: 100%; 
 
    height:200px; 
 
} 
 

 
img{ 
 
    width: 400px; 
 
    height:50px 
 
} 
 

 
.figure{ 
 
    text-align: center; 
 
} 
 

 
.caption{ 
 
    text-align: left; 
 
}
<div class="container"> 
 
<figure class="figure"> 
 
<img src=""/> 
 
<figcaption class="caption"> 
 
This is my caption. 
 
</figcaption> 
 
</figure>

+1

あなたはそれを左に揃えたい場合は、なぜ中央に整列 '.figure'はありますか? – RobertAKARobin

+0

イメージを親コンテナの中央に揃えたいが、その下にあるキャプションを中央のイメージの左端に合わせる。 –

答えて

2

のように見えるしたいと思います。

.container{ 
 
    width: 100%; 
 
    height:200px; 
 
} 
 

 
#imgWrap 
 
{ 
 
    display: inline-block; 
 
} 
 
img{ 
 
    width: 400px; 
 
    height:50px 
 
} 
 

 
.figure{ 
 
    text-align: center; 
 
} 
 

 
.caption{ 
 
    text-align: left; 
 
}
<div class="container"> 
 
    <figure class="figure"> 
 
     <div id='imgWrap'> 
 
      <img src=""/> 
 
      <figcaption class="caption"> 
 
       This is my caption. 
 
      </figcaption> 
 
     </div> 
 
    </figure> 
 
</div>

0

プロパティをテキスト整列それは '中心' として指定されているように、中心に "数字" を整列させます。

「left」に変更するか、まったく指定しないでください。

.container{ 
 
    width: 100%; 
 
    height:200px; 
 
} 
 

 
img{ 
 
    width: 400px; 
 
    height:50px 
 
} 
 

 
.figure{ 
 
    
 
} 
 

 
.caption{ 
 
    
 
}
<div class="container"> 
 
<figure class="figure"> 
 
<img src=""/> 
 
<figcaption class="caption"> 
 
This is my caption. 
 
</figcaption> 
 
</figure>

+0

ご迷惑をおかけして申し訳ありませんが、画像の中心を揃えておきたいと思います。 –

関連する問題