A
A
artekha2017-03-08 13:24:49
css
artekha, 2017-03-08 13:24:49

How to set relative height?

Hello, I need to somehow set the relative height, so that when the width changes, the height adjusts, let's say the element has a width of 1000px, so the height should be 300px, if you increase the width to 3000px, the height will be 600px, in general, you need the height to always be 30 % of width.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Саша, 2017-03-08
@userAlexander

Пробуйте на JS, а мы поможем)

Александр Филиппенко, 2017-03-08
@alexfilus

Если ширина контейнера как-то соотносится с шириной окна (экрана), то можно высоту задать в vw.

Григорий, 2017-03-09
@gregst

а через css переменные нельзя?
Типа
--container-width: 1000px;
height: calc(var(--container-width) / 3);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question