Grow your CSS skills. Land your dream job.

css fixed center background image

  • # March 11, 2012 at 6:14 pm

    I used the code off from this website for a fixed centered background image and for some reason the image covers the whole page. I tried to make a z-index attribute for it, but then it dissapeared…here is the code in question..

    #bg {
    position:fixed;
    top:-50%;
    left:-50%;
    width:200%;
    height:200%;
    }

    #bg img {
    position:absolute;
    top:0;
    left:0;
    right:0;
    bottom:0;
    margin:auto;
    min-width:50%;
    min-height:50%;
    }

    it also seems to be now competely out of alignment…wasnt like this when i first put the code up??

    http://www.ontariobuyersmarket.ca/exclusive-properties/

    # March 11, 2012 at 6:45 pm

    Have a look at this, tell me what you think.

    http://jsfiddle.net/kQYbN/

    # March 11, 2012 at 6:52 pm

    well its centered just fine…but its still overlapping most everything on the page, take a look

    http://www.ontariobuyersmarket.ca/exclusive-properties/

    # March 11, 2012 at 6:59 pm

    Hmm…you need to make sure that the HTML code is pasted right after the body tag.

    # March 11, 2012 at 7:13 pm

    gotcha…but how would you do that within wordpress…the body tags are not viewable within the edit page feature

    # March 11, 2012 at 7:25 pm

    getting closer tracking the body tag down…

    # March 11, 2012 at 7:26 pm

    Good question, try putting it before the first div tag in your code. Or if you can copy the code from wordpress into JSFiddle and I’ll see what I can do.

    # March 11, 2012 at 7:42 pm

    The BODY tag you’ll find in HEADER.PHP.

    Make sure you learn a little about the basics of WordPress before you start fiddling with its many options and start editing files, it’s very easy to screw things up.

    # March 11, 2012 at 7:53 pm

    well the problem is that from what im reading usually the body tags within wordpress are in the header.php file….but i have sifted through a lot of these files and i cant find a single body tag

    # March 11, 2012 at 7:55 pm

    yep, i know this…im pretty good with wordpress…though this is a new theme for me and i cannot find the body tag anywhere

    # March 11, 2012 at 8:16 pm

    i give up for tonight…ive tried header, footer, page, index…nothin

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".