Reputation: 13555
Here is the test link:
Right now on mobile device, is scroll to middle horizontally,
I would like to achieve is like this
the container is full width on the mobile and disable to scroll horizontally
Here is the code:
<meta name="viewport" content="width=device-width, initial-scale=0.5">
And scroll to middle
scrollTo(($(document).width() - $(window).width()) / 2, 0);
The background is set to 1903px as doesn't want the center content move left when resize the window
Thanks a lot for helping.
Upvotes: 0
Views: 87
Reputation: 2963
You are doing some things with your layout that will cause it to not work well responsively and the viewport measurements will probably be off (I don't have the proper device to test this but fixing these things should fix your problem):
Set initial scale to 1. Why do you have it set for .5? I imagine to compensate for your layout issues? Your static width for the content container won't allow it to be responsive which is probably what you're fighting against.
Set .my_box { max-width: 1903px; }
.my_box container inline style set to no-repeat, scroll, and center center, then use background-size: cover so it always fits:
background: transparent url("./assets/image/bg5.jpg") no-repeat scroll center center / cover; background-size: cover; }
Let me know how this goes.
Upvotes: 1