Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flexbox row won't work, forces column layout

Tags:

html

css

flexbox

I try to learn flexbox and do some project using it but whenever I set my container to display: flex my rows are turned into columns and flex-direction property like doesn't respond, it won't make them into rows.

What am I doing wrong? I'm going insane because of this, current code looks like this:

.container {
  width: 60vw;
  height: 45vw;
  display: flex;
}

.row {
  flex-basis: 300px;
  flex-direction: row;
}
<div class="container">
  <div class="row" style="background: red"></div>
  <div class="row" style="background: blue"></div>
</div>
like image 555
BigPaws Avatar asked Apr 25 '26 13:04

BigPaws


1 Answers

For the items to stack vertical and create rows, you set the direction to column

Note, the property flex-direction should be set on the flex container, not its items

.container {
  width: 60vw;
  height: 45vw;
  display: flex;
  flex-direction: column;
}

.row {
  flex-basis: 300px;
}
<div class="container">
  <div class="row" style="background: red"></div>
  <div class="row" style="background: blue"></div>
</div>
like image 177
Asons Avatar answered Apr 28 '26 04:04

Asons



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!