Align image in center

on Thursday, 13 February 2014


Code :
<div class="img-contain">
<img alt="hello" src="dd.jpg" class="center-img">
</div>
CSS :
 
First Solution and best Solution : 
 
 div.img-contain
{
 height: 500px;
 width: 100%;
}
.center-img
{
 margin: auto;
 display: block;
 height: 100px;
 width: 100px;
    /*** if position is absolute ****/
 left: 0;
 right: 0;
 position: absolute;
}
 
 Second Solution is :
 
 div.img-contain
{
 height: 500px;
 width: 100%;
    text-align: center;
}
.center-img
{
   display: block;
 /*** if position is absolute ****/
 left: 0;
 right: 0;
 position: absolute;
    }


1 comments :

Anonymous said...

thanks

Post a Comment