2016-09-07 15 views
0

画像が左に浮かんでいます。テキストが画像の中央にくるように、テキストを画像に垂直に整列させたいと思います。画像とテキストの垂直方向の整列

どうすればいいですか?私はこのサイトで提供された多くのソリューションを試しましたが、誰も私のために働いていません。

以下に示すように、this solutionは機能しません。

/* Limiting outter width to illustrate the problem */ 
 

 
.cart-helper-outer { 
 
    width: 200px; 
 
} 
 
/* Makes helper items full width */ 
 

 
.cart-helper-inner { 
 
    width: 100%; 
 
    float: left; 
 
} 
 
/* Displays image left of text */ 
 

 
.cart-helper-inner img { 
 
    max-width: 50px; 
 
    float: left; 
 
    margin-right: 2.5%; 
 
    vertical-align: middle; /* this does not work*/ 
 
} 
 
.cart-helper-inner p { 
 
    vertical-align: middle; /* this also doesn't work*/ 
 
}
<div class="cart-helper-outer"> 
 
    <div class="cart-helper-inner"> 
 
    <img src="http://placehold.it/50x50" /> 
 
    <p>Secure checkout with bank grade encryption</p> 
 
    </div> 
 
    <div class="cart-helper-inner"> 
 
    <img src="http://placehold.it/50x50" /> 
 
    <p>Secure checkout with bank grade encryption</p> 
 
    </div> 
 
    <div class="cart-helper-inner"> 
 
    <img src="http://placehold.it/50x50" /> 
 
    <p>Secure checkout with bank grade encryption</p> 
 
    </div> 
 
</div>

答えて

0

/* Limiting outter width to illustrate the problem */ 
 

 
img{ 
 
margin:15px 0px; 
 
} 
 
.cart-helper-outer { 
 
    width: 200px; 
 
} 
 
/* Makes helper items full width */ 
 

 
.cart-helper-inner { 
 
    width: 100%; 
 
    float: left; 
 
} 
 
/* Displays image left of text */ 
 

 
.cart-helper-inner img { 
 
    max-width: 50px; 
 
    float: left; 
 
    margin-right: 2.5%; 
 
    vertical-align: middle; /* this does not work*/ 
 
} 
 
.cart-helper-inner p { 
 
    vertical-align: middle; /* this also doesn't work*/ 
 
}
<div class="cart-helper-outer"> 
 
    <div class="cart-helper-inner"> 
 
    <img src="http://placehold.it/50x50" /> 
 
    <p>Secure checkout with bank grade encryption</p> 
 
    </div> 
 
    <div class="cart-helper-inner"> 
 
    <img src="http://placehold.it/50x50" /> 
 
    <p>Secure checkout with bank grade encryption</p> 
 
    </div> 
 
    <div class="cart-helper-inner"> 
 
    <img src="http://placehold.it/50x50" /> 
 
    <p>Secure checkout with bank grade encryption</p> 
 
    </div> 
 
</div>

+0

真ん中には、テキストのアライメントを行いません。それは上部に揃えられています。 – bennygill

関連する問題