css - Vertically centering an image and a text -


i using twitter bootstrap , grid layout , in 1 column trying image pulled right , text pulled right next image while should both vertically centered. image it's easy - made class img-responsive , added padding column , pull-right image sits well, text doesn't seem center whatever try.

i tried applying column:

.center{     display : table-cell;     vertical-align : middle;     float:none; } 

and seemed work when there's text, image included won't.

here code column:

<div class="col-md-3 col-xs-6 col-md-push-4 equalcolumn" id="namecolumn">         <img class="pull-right img-circle img-responsive" id="myimage" src="http://upload.wikimedia.org/wikipedia/en/0/03/super_mario_bros._box.png" alt="">         <h4 class="pull-right" id="nametext">welcome!</h4> </div> 

and css:

#namecolumn {     padding: 1vh;  } .img-responsive { height: 100%; margin: 0 auto; } 

thanks!

h4 block element, set inline-block , give vertical-align:middle; both img , h4 , center each other on baseline.

#myimage, #nametext {     display:inline-block;/* defaut display of img tag */     vertical-align:middle; } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -