I would like to center some div which has background image. There is problem with response of this div, because if I set width on 80% and height on 80% the bg-image is not on center. I tried everything, but the picture can’t just stand on center and if the browser is smaller or bigger this is very big problem.
So if you look at the picture

I want to make this white block responsive.
There is a little of css which I’ve already written, but for now is non-responsive:
top: 20%;
left: 30%;
display: block;
position: absolute;
background: url(images/background.png) no-repeat;
background-size: 750px 417px;
width: 750px;
height: 417px;
I wanted to do the same thing 2 years ago, there’s the solution:
Because you want it responsive, you may use the
@mediafunction in CSS3. Like this:The
max-widthyou use is the maximum width of the device screen. You just copy it and change thewidth, height, margin-left and margin-topfor the image. Also, you should change thebackgroundtag!It will center the image on the page.
You can see an exemple at: Créations MicroWeb – Carrières. The image is totally centered even if you change the window side.
You can add
overflow: hidden;on thebodyto make the page unscrollable when the resolution is too low. Like I did.EDIT: JSFiddle