E
E
Evgeny Babkin2015-09-26 15:19:29
css
Evgeny Babkin, 2015-09-26 15:19:29

How to center an absolutely positioned element?

Actually, here is an example of the layout
codepen.io/heyjoe/pen/ZbBOPG
The problem is that when the width of the browser window changes (downwards), the centering disappears.
Can you please tell me how to set the centering of the input-wrapper element so that it takes effect when the width of the browser window changes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Turovnikov, 2015-09-26
@hey_joe

With unknown width and height, you can do this:

top:50%;
left:50%;
transform:  translate(-50%,-50%);
-webkit-transform:  translate(-50%,-50%);
-moz-transform:  translate(-50%,-50%);
-o-transform:  translate(-50%,-50%);
-ms-transform:  translate(-50%,-50%);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question