Skip to content

Instantly share code, notes, and snippets.

@amitabhaghosh197
Last active September 9, 2017 15:27
Show Gist options
  • Save amitabhaghosh197/2c0dc00572e6428693858d051fe412cf to your computer and use it in GitHub Desktop.
Save amitabhaghosh197/2c0dc00572e6428693858d051fe412cf to your computer and use it in GitHub Desktop.
css&HTML importants #css #center-image
Position images to center always

Always add a helper class and .helper{ display:inline-block; height:100%;}



<div class="col_featured-image">
 <span class="helper"></span><img src="assets/img/features_tie.png">
</div>
<h1>Tieups</h1>

<style>
 .col_featured-image{
    width: 102px;
    height: 83px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 47px;
    overflow:hidden;
}

.col_featured-image > img{
	max-width: 100%;
	max-height: 100%;
	display: inline-block;
	vertical-align: bottom;
	/*position: absolute;
    left: 50%;
    bottom: 0;
    -webkit-transform: translate(-50%, 0);
    -moz-transform: translate(-50%, 0);
    transform: translate(-50%, 0);*/
}

.helper{
	
	display:inline-block;
	height:100%;
	vertical-align:bottom;
}

</style>

Reff:

  1. http://stackoverflow.com/questions/7273338/how-to-vertically-align-an-image-inside-div
  2. http://jsfiddle.net/kizu/4RPFa/4570/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment