G
G
Gleb Stavinsky2015-10-12 21:38:56
css
Gleb Stavinsky, 2015-10-12 21:38:56

How to make a square div on pure css, which has percentage dimensions and is nested in div = monitor screen?

Hello.
I will not indicate all the data, I will explain in general, I think it will be clear.
The bottom line is, there is a div with parameters width: 100% and height: 100% equal to the browser screen.
You need to place a div = square in it, but its sides or side are specified strictly in percentages in order to maintain adaptability. For example width: 50% and margin: 10% 0 0 10%;
I know how to do it using scripts, the question is: can it be done with pure css?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ivanq, 2015-10-12
@gleb_se

In CSS, there are types vh and vw - the height of the screen and its width, respectively. You can put for div:

width: 50vw;
height: 50vw;

@
@ksider, 2015-10-12
_

there is a cool hack

.b {
width:20%;
padding-bottom:20%;
}

G
Gleb Stavinsky, 2015-10-12
@gleb_se

Thanks to all!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question