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)
3 Answers
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.