Skip to content

Commit

Permalink
use flexbox to center blocks inside layout
Browse files Browse the repository at this point in the history
  • Loading branch information
MaggieCabrera committed May 28, 2021
1 parent 12a6e4b commit 7054700
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,15 @@ function gutenberg_render_layout_support_flag( $block_content, $block ) {

$style = '';
if ( $content_size || $wide_size ) {
$style = ".wp-container-$id > * {";

$style = ".wp-container-$id {";
$style .= 'display: flex;';
$style .= 'flex-flow: column;';
$style .= 'align-items: center;';
$style .= '}';

$style .= ".wp-container-$id > * {";
$style .= 'box-sizing: border-box;';
$style .= 'max-width: ' . esc_html( $all_max_width_value ) . ';';
$style .= 'margin-left: auto !important;';
$style .= 'margin-right: auto !important;';
Expand Down
8 changes: 8 additions & 0 deletions packages/block-editor/src/components/block-list/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ export function LayoutStyle( { selector, layout = {} } ) {
let style =
!! contentSize || !! wideSize
? `
${ selector } {
display: flex;
flex-flow: column;
align-items: center;
}
${ appendSelectors( selector, '> *' ) } {
box-sizing: border-box;
width: 100%;
max-width: ${ contentSize ?? wideSize };
margin-left: auto !important;
margin-right: auto !important;
Expand Down

0 comments on commit 7054700

Please sign in to comment.