Last active
November 16, 2017 04:24
-
-
Save braddalton/c4386aaacb3488c9219063ebfa4473f6 to your computer and use it in GitHub Desktop.
Split Widgets Using CSS Grid in Genesis https://wpsites.net/web-design/split-widgets-50-width-each/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
genesis_register_sidebar( array( | |
'id' => 'left', | |
'name' => __( 'Left' ), | |
) ); | |
genesis_register_sidebar( array( | |
'id' => 'right', | |
'name' => __( 'Right' ), | |
) ); | |
add_action( 'genesis_after_header', 'inline_widgets' ); | |
function inline_widgets() { | |
if ( is_active_sidebar( 'left' ) || is_active_sidebar( 'right' ) ) { | |
echo '<div class="grid-wrapper">'; | |
genesis_widget_area( 'left', array( | |
'before' => '<div class="left widget-area">', | |
'after' => '</div>', | |
) ); | |
genesis_widget_area( 'right', array( | |
'before' => '<div class="right widget-area">', | |
'after' => '</div>', | |
) ); | |
} | |
echo '</div>'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.left { | |
grid-area: left; | |
} | |
.right { | |
grid-area: right; | |
} | |
.grid-wrapper { | |
padding-top: 40px; | |
padding-left: 40px; | |
padding-right: 40px; | |
display: grid; | |
grid-gap: 40px; | |
grid-template-columns: 1fr 1fr; | |
grid-template-areas: "left right"; | |
} | |
@media only screen and (max-width: 1023px) { | |
.grid-wrapper { | |
display: grid; | |
grid-gap: 0; | |
grid-template-columns: 1fr; | |
grid-template-areas: | |
"left" | |
"right"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment