D
D
dk-web2015-11-07 16:33:12
css
dk-web, 2015-11-07 16:33:12

How to leave a block in the middle?

Hello!
Short question.. how to keep the blue block in place by pushing the blue and green off the screen?
Also set it to absolute positioning?
jsfiddle.net/fo8yz20y/1

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilyusha Prokopiev, 2015-11-07
@iliapro

Yes, install it position:absoluteand add padding from the left edge

N
Nash, 2015-11-08
@mrTyler

You don't need to add any padding, the code below will make the block element always in the center.
The indented solution won't give you universality on different screens.
Note that the position of an absolute box depends on who its parent is and whether there is position: relative above.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question