how to delete margin-top: 32px !important from twenty twelve

I want to remove the margin-top property from twenty twelve theme. This is the default theme provided by wordpress. The sample of the code what I found with the help of firebug.

html{
     margin-top: 32px !important;
    }

Related posts

Leave a Reply

12 comments

  1. A better way to do this is to add theme support for the admin bar with a callback of “return false”, then WordPress wont ever trigger the _admin_bar_bump_cb action which is responsible for adding in the margin-top:32px.

    add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) );
    
  2. Add the following function to your functions.php file

    function my_function_admin_bar(){ return false; }
    add_filter( 'show_admin_bar' , 'my_function_admin_bar');
    
  3. Go to the functions file inside your theme folder:

    functions.php

    add_action('get_header', 'remove_admin_login_header');
    
    function remove_admin_login_header() {
        remove_action('wp_head', '_admin_bar_bump_cb');
    }
    
  4. I think it is because you are logged in in your wordpress account and that 32px space corresponds to the black menu line that is on the top of your page, which doesn’t appear but leaves the space for it . Log out and refresh the page and see if it continues or open the website in an other browser.

  5. in the style.css around line #1645 is body .site { which has padding top & bottom:

    body .site {
        padding: 0 40px;
        padding: 0 2.857142857rem;
        margin-top: 48px;
        margin-top: 3.428571429rem;
        margin-bottom: 48px;
        margin-bottom: 3.428571429rem;
        box-shadow: 0 2px 6px rgba(100, 100, 100, 0.3);
    }
    
  6. In dashboard in sidebar go to Users -> Profile,then in profile uncheck “Show Toolbar when viewing site”.Update changes and margin-top will disapear.
    That’s where the margin comes from.