C
C
chelkaz2018-05-16 11:08:29
css
chelkaz, 2018-05-16 11:08:29

Flex Vertical - Percentages and Pixels. How to align?

There is a main block, in full screen. in height 100%
In it you need to arrange horizontally 2 blocks so that the bottom one is 200px, and the top one is all the rest of the space.
5afbe6f3c0fbb045539607.jpeg

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Ankhena, 2018-05-16
@Ankhena

There is flex:1, there is calc
https://jsfiddle.net/j4wpxLgp/

M
meshoot, 2018-05-16
@meshoot

Parent do:

div {
   display: flex;
   flex-direction: column;
   justify-content: space-between;
}

We do for children:
.top {
   height: calc(100% - 200px);
}

.bottom {
  flex: 0 0 200px;
}

C
CODALSD, 2018-05-16
@CODALSD

<div class="flex row">
  <span class="t2 flex column">
    <em class="t1"></em>
    <em class="t2"></em>
  </span>
</div>

.flex {
  display:flex;
}
.row {
  flex-direction:row;
}
.column {
  flex-direction:column;
}
.t1 {
  flex:1 1 100%;
}
.t2 {
  flex:1 1 200px;
}
div {
  width:100%;
  height:100vh;
  background:blue;
}
.flex.column {
  background:red;
}
.column .t1 {
  background:green;
}

Something like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question