Stack divs on top of each other using bootstrap flexbox

Jeff Benister

Sorry for the newbie post but I am new to bootstrap (using version 4.0) and have been doing a lot of reading but have not been able to achieve the simple task of stack two divs on top of each other.

<div class="d-flex flex-column">
  <div style="background: blueviolet">
    Flex item 1
  </div>
  <div style="background: burlywood">
    Flex item 2
  </div>
</div>

My aim is to have Flexbox 1 50% height and Flexbox 2 fill the remaining height or have Flexbox 1 at 40% height and have Flexbox 2 fill the remaining space.

I have been following bootstrap documentation to learn. What other resources could I look into?

Thank you for the help.

huan feng

You can use the class flex-fill to auto-fill for the rest of the space.

Try to adjust the height of class .item-1 to see the result.

https://jsfiddle.net/ramseyfeng/bqvwcLe5/1/

html,body {
  height: 100%;
}

.item-1 {
  height: 50%;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css" rel="stylesheet"/>
<div class="d-flex flex-column h-100">
  <div style="background: blueviolet" class="item-1">
    Flex item 1
  </div>
  <div style="background: burlywood" class="flex-fill">
    Flex item 2
  </div>
</div>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Divs stack on top of each other

How to Stack Divs on top of each other

Aligning 2 DIVs on top on each other in bootstrap

How to stack divs on top of each other when screen gets smaller? bootstrap

How do I stack divs on top of each other in a form box?

How to make flexbox responsive and stack 1 on top of each other

Stacking divs on top of each other

Is there a way to position divs on top of each other without using position absolute?

How to stack multiple images on top of each other using python or matlab?

When I'm under a specific width, my divs all stack on top of each other

Why do 2 .col divs stack on top of each other and how to repeat this on the opposite side in boostrap?

Divs stack each other upon zoom

jQuery: divs on top of each other while this is not needed

Stacking two divs on top of each other

How to display divs on top of each other?

Why is my DIVs going on top of each other?

Two divs on top of each other for team page

R: "stack" columns on top of each other

Android Cardview elements stack on top of each other

android image stack on top of each other horizontally

Stack groups in a DataFrame on top of each other

draggable items stack on top of each other in a sortable

Stack flex items on top of each other

How to stack items on top of each other?

How to Stack Arrays on top of Each Other

The Div's stack on top of each other

How to stack HTML elements on top of each other

Bootstrap flexbox columns next to each other instead of under each other

Two styled divs next to each other [flexbox/ responsive]