• Resolved tomgelder

    (@tomgelder)


    Using a child of Twenty Twelve, I’ve been adding color to all the major containers (#main, #content, #secondary, etc.) using

    #arbitrary-id {
     background-color: #dedede;
    }

    This works for everything but body. I should be more clear: it changed the body background color until I messed with the background color in “Appearance>Background”. Now no matter what I try, I can’t override that.

    Looking in the HTML of the page and inside the <head> I see

    <style type="text/css" id="custom-background-css">
    body.custom-background { background-color: #e6e6e6; }
    </style>

    Naturally, I tried to change the color using that selector, but since it’s generated internally, that trumps the external CSS.

    I’m at a total loss for how to do this. How do I change the background color of the body using CSS?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The #e6e6e6 is the default if you don’t put in your own color under Appearance > Background, also for TwentyTwelve it automatically add #fff if you leave it empty.

    So just go set it with color other than white, like #fffffe, and your code should work.

    Or use this in your child theme’s style.css to override all that.

    @media screen and (min-width: 960px) {
    	html > body,
    	html > body.custom-background,
    	html > body.custom-background-empty {background-color:red;}
    }
    Thread Starter tomgelder

    (@tomgelder)

    Got it answered over on Stack Exchange.
    I quote from user s_ha_dum:

    It sounds like you just need to remove support for the custom background color.

    remove_theme_support( 'custom-background' );

    You will probably need to hook it to get it to run after the parent functions.php

    function disable_bg_wpse_97248() {
        remove_theme_support( 'custom-background' );
    }
    add_action('after_setup_theme','disable_bg_wpse_97248',100)

    I just added that function to my child’s functions.php and it worked like a charm.

    Thread Starter tomgelder

    (@tomgelder)

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Changing background-color from style.css’ is closed to new replies.