0

so I've got this layout that works fine in desktop screen: look at top image.

enter image description here

But when in mobile layout/zoomed in it becomes this: (look at middle image).

So what i'm trying to achieve is for the image to be zoomed in to the center like background size cover behavior. (look at bottom image)

Can anyone help me on this layout issue? Thanks in advance.

Suneel Kumar
  • 1,650
  • 2
  • 21
  • 31
Erwin Sanders
  • 296
  • 1
  • 12

2 Answers2

0

Use flexbox to solve this.

.center {
  display: flexbox;
  justify-content: center;
}

Apply this .center class to container box.

Check out this link for browser support for flexbox.

Abhinav Jain
  • 329
  • 1
  • 2
  • 9
0

you can make img as absolute and add

img{
   left:0;
   right:0;
   margin: auto;
   overflow:hidden;
}
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Manik Biradar
  • 1,294
  • 2
  • 9
  • 7