Gutenberg: Grid system is not responsive for the columns block

Created on 7 Dec 2018  路  6Comments  路  Source: WordPress/gutenberg

On width 600px the 2 columns fall under each other and create an empty space on the right. But they should fill the whole space. This issue is the same with more than 2 columns.

To Reproduce

  1. Add 2 columns
  2. Make the width little smaller than 600px
    image

Possible fix
wp-block-column is using margins for gaps:
image

Using paddings will fix this issue.

Needs Testing [Block] Columns

Most helpful comment

Sure, here are the CSS rules that solved an issue for me:

.has-3-columns > .wp-block-column:last-child {
  margin-right: 0;
}

@media (max-width: 781px) {

  .has-2-columns > .wp-block-column,
  .has-3-columns > .wp-block-column,
  .has-4-columns > .wp-block-column {
    flex-basis: calc(50% - 32px);
    flex-grow: 0;
  }

  .has-4-columns > .wp-block-column:nth-child(odd) {
    margin-left: 0;
    margin-right: 32px;
  }

  .has-4-columns > .wp-block-column:nth-child(even) {
    margin-right: 0;
  }

  .has-3-columns {
    flex-flow: row wrap;
  }

  .has-3-columns .wp-block-column:first-child {
    flex-basis: 100%;
    margin-right: 0;
  }

  .has-3-columns > .wp-block-column:nth-child(even) {
    margin-left: 0;
    margin-right: 32px;
  }

  .has-3-columns > .wp-block-column:nth-child(odd) {
    margin-right: 0;
  }
}

@media (max-width: 599px) {
 .has-2-columns > .wp-block-column,
 .has-3-columns > .wp-block-column,
 .has-4-columns > .wp-block-column {
  flex-basis: 100%;
  margin-left: 0 !important;
  margin-right: 0 !important;
 }
}

All 6 comments

Possibly related: #12640.

The Wordpress 5.1 is out but this issue still remains...

@IvanPr This kind of comments on multiple issues don't really help. If you want to move things forward, maybe you could take a stab at these?

Sure, here are the CSS rules that solved an issue for me:

.has-3-columns > .wp-block-column:last-child {
  margin-right: 0;
}

@media (max-width: 781px) {

  .has-2-columns > .wp-block-column,
  .has-3-columns > .wp-block-column,
  .has-4-columns > .wp-block-column {
    flex-basis: calc(50% - 32px);
    flex-grow: 0;
  }

  .has-4-columns > .wp-block-column:nth-child(odd) {
    margin-left: 0;
    margin-right: 32px;
  }

  .has-4-columns > .wp-block-column:nth-child(even) {
    margin-right: 0;
  }

  .has-3-columns {
    flex-flow: row wrap;
  }

  .has-3-columns .wp-block-column:first-child {
    flex-basis: 100%;
    margin-right: 0;
  }

  .has-3-columns > .wp-block-column:nth-child(even) {
    margin-left: 0;
    margin-right: 32px;
  }

  .has-3-columns > .wp-block-column:nth-child(odd) {
    margin-right: 0;
  }
}

@media (max-width: 599px) {
 .has-2-columns > .wp-block-column,
 .has-3-columns > .wp-block-column,
 .has-4-columns > .wp-block-column {
  flex-basis: 100%;
  margin-left: 0 !important;
  margin-right: 0 !important;
 }
}

This seems fixed in my testing.

Was this page helpful?
0 / 5 - 0 ratings