Skip to content

Instantly share code, notes, and snippets.

@keithdevon
Last active December 18, 2020 22:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keithdevon/7ff062427f33177e1272cc1f38602f6c to your computer and use it in GitHub Desktop.
Save keithdevon/7ff062427f33177e1272cc1f38602f6c to your computer and use it in GitHub Desktop.
Gutenberg columns block alignment fix
:root {
--gutter: 32px;
}
@media screen and (min-width: 782px) {
/* For the '25's' in the 25 / 50 / 25 variation */
.wp-block-column[style='flex-basis:25%'] {
flex-basis: calc(var(--gutter) * 2) !important;
flex-grow: 1;
}
/* For the '50' in the 25 / 50 / 25 variation */
.wp-block-column[style='flex-basis:50%'] {
flex-basis: calc(var(--gutter) * 5) !important;
flex-grow: 2;
}
/* For the '30' in the '70 / 30' variation */
.wp-block-column[style='flex-basis:33.33%'] {
flex-basis: calc(var(--gutter) * 3) !important;
flex-grow: 1;
}
/* For the '70' in the '70 / 30' variation */
.wp-block-column[style='flex-basis:66.66%'] {
flex-basis: calc(var(--gutter) * 7) !important;
flex-grow: 2;
}
}
@keithdevon
Copy link
Author

This code will fix the alignment of the default column block variations. Specifically the '70 / 30', '30 / 70', and '25 / 50 / 25' variations.

It does this by targeting the specific style="flex-basis: X%" attribute that is added to these variations.

If a custom column width is set, the code will no longer affect the alignment and will use the default styling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment