1

Where is this CSS code?

I mean the margin-top: 46px !important!; I need to change it to 1px to rid of top margin. But i didn't found it in any theme's files.

Note: I have searched the texts in all files using FileSeek Pro. But didn't found anything. (even with Inspect Element in the Firefox)

enter image description here

  • 2
    Could you load the page with the Javascript being deactivated in your browser? This inline style may have been added through Javascript. – Mike May 27 '18 at 13:40
5

The CSS code you're seeing is added by core of WP when admin bar is showing.

The function that outputs it is called _admin_bar_bump_cb() and it's called as hook on wp_head.

So how to get rid of it? Just remove this action from that hook:

function remove_admin_bar_bump() {
   remove_action( 'wp_head', '_admin_bar_bump_cb' );
}
add_action('get_header', 'remove_admin_bar_bump');

Then you can add it in your CSS and use body.admin-bar as context if you want to add some styles only if the admin bar is visible.

3

Here's what you can do about this:

  • There may be a plugin which is loading this CSS so try disabling all the plugins?
  • Please check the "Addional CSS" in the customizer and check if the code is there, or check if there is any Custom CSS plugin installed and this is inserted in it. Also check the style.css file in your theme.
  • Add additional CSS yourself by adding a code like this and overriding this? Here's the code:
    html {margin-top: 1px !important;}

If any of these doesn't fix the issue, please let me know which theme are you using.

  • Well, this code isn't added by any plugin... It's added by WordPress core. – Krzysiek Dróżdż May 27 '18 at 14:15
1

If you can't see it in view source code ( ctrl + u ), probably javascript added it.

And also, is this only available when you're logged in? I think it caused by the WordPress admin bar.

Regards, Renz

Not the answer you're looking for? Browse other questions tagged or ask your own question.