center image css

CSS
.center {
  display: block;
  margin-left: auto;
  margin-right: auto;
}.centerImg {
  display: block;
  margin: 0 auto;
}.center {
  margin: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}<div style="text-align: center;">
  <img scr='img/example.jpg'>
</div>  <style>
.content {
  max-width: 500px;
  
  margin: auto;
}
</style>

  <body>

<div class="content">
  <!-- Page content -->
</div>

</body>   .center {
  display: block;
  
  margin-left: auto;
  margin-right: auto;
  
  width: 50%;
} 
Source

Also in CSS: