簡體   English   中英

將標題垂直居中對齊

[英]Align Caption Left of Vertically Centered Image

在下面的示例中,是否有一種簡單的方法將標題與居中圖像的左邊緣對齊?

當前顯示如下:

      ____________________
     |                    |
     |                    |
     |                    |
     |                    |
     |____________________|
 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> 

您可以這樣做。

 .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> 

text-align屬性將“數字”與中心對齊,因為它被指定為“中心”。

因此,將其更改為“左”或根本不指定它。

 .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> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM