Skip to content

Instantly share code, notes, and snippets.

@justintadlock
Created June 4, 2021 04:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justintadlock/70180c2019f1e2dbdda96ee263610671 to your computer and use it in GitHub Desktop.
Save justintadlock/70180c2019f1e2dbdda96ee263610671 to your computer and use it in GitHub Desktop.
Offset left and right Cover block styles
<?php
add_action( 'init', function() {
register_block_style( 'core/cover', [
'name' => 'offset-left',
'label' => __( 'Offset Left' ),
'inline_style' =>
'.wp-block-cover.is-style-offset-left > .wp-block-cover__inner-container {
background-color: inherit;
color: inherit;
padding: inherit;
}
@media ( min-width: 768px ) {
.wp-block-cover.is-style-offset-left > .wp-block-cover__inner-container {
width: 75%;
margin-left: -75%;
}
}'
] );
register_block_style( 'core/cover', [
'name' => 'offset-right',
'label' => __( 'Offset Right' ),
'inline_style' =>
'.wp-block-cover.is-style-offset-right > .wp-block-cover__inner-container {
background-color: inherit;
color: inherit;
padding: inherit;
}
@media ( min-width: 768px ) {
.wp-block-cover.is-style-offset-right > .wp-block-cover__inner-container {
width: 75%;
margin-right: -75%;
}
}'
] );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment