B
B
beduin012017-08-10 14:01:43
JavaScript
beduin01, 2017-08-10 14:01:43

Is it possible to set the height of a flexbox container as a percentage?

I need to fit a div into a flex-box container so that it takes up 90% of the height. Everything is fine with the width, but the width cannot be set as a percentage. You can only fixed in pixels.

.LeftContainerTop
{
  border: 1px solid green;
  flex-grow: 0.4;
  display: flex;
  align-items: center;
  justify-content: center;
}

.SliderInContainerOnMainPage
{
  border: 1px solid red;
  flex-grow: 1;
 // вот тут
}

50b1c1f62fe24a5aab02fc3945da25f1.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
profesor08, 2019-03-28
@illiatovpeko

The code should be at the end of the page, or loaded after all html elements are loaded. res.onkeypresswill be nullbecause the click event you set forinp

V
Vladislav Lyskov, 2017-08-10
@beduin01

https://jsfiddle.net/39ar5u3a/

M
Maxim Timofeev, 2017-08-10
@webinar

An element can only be stretched x% height from its parent if you give the parent a clear height
https://jsfiddle.net/ceb6hrdL/2/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question