Skip to content

Instantly share code, notes, and snippets.

@currentcreative
Last active May 19, 2023 16:31
Show Gist options
  • Save currentcreative/b2dc1800cb8d9f5342ea6a582238019b to your computer and use it in GitHub Desktop.
Save currentcreative/b2dc1800cb8d9f5342ea6a582238019b to your computer and use it in GitHub Desktop.
Remove weird spacing above Admin bar when testing mobile view in browser
/* ADD THIS TO functions.php */
// REMOVE MARGIN FROM WP ADMIN BAR during mobile testing
add_theme_support( 'admin-bar', array( 'callback' => 'my_admin_bar_css') );
function my_admin_bar_css()
{
?>
<style type="text/css">
@media screen and (max-width: 600px) {
html body { margin-top: 0 !important; }
html { padding-top: 46px; }
}
@media screen and (min-width: 601px) {
html { margin-top: 32px; }
}
</style>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment