I need to center the div in the viewport in a container greater than 100%.
assuming it is 160% larger, I prepared this fiddle:
https://jsfiddle.net/mz0bbz14/2/
usually I would go:
position:absolute;
top:50%;
left:50%;
transform:translate(-50%,-50%);
but it only works when its container is 100% larger.
he decided with this css
position:absolute;
top:50%;
text-align: center;
transform:translate(0,-50%);
width: 100vw;
but the block vw
does not work in old browsers for Android, and I need to support it. I cannot use jQuery, and I do not know how to focus it on pure javascript.
I tried setting it .div
to half the width of the container, but the text inside the div is not visually centered.
I can not find a solution. any ideas? thanks