Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Problem With Repeating Background

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #31497
    mwdewitt
    Member

    I am very new to this, so this might be a really stupid question, but I am having trouble with creating a repeating background, on the top of my page, along the x-axis.

    I am using the following code:

    body {background: url(/wp-content/themes/blank/images/body-bg.png) top center repeat-x white;}

    I am following along with one of the tutorials on WordPress from CSS-Tricks and it seems like it should work. I did everything that Chris Coyier did in his own video, and yet when I load my index.php file, the background does not appear. Then, when I right-click on the window and say “View Background Image,” it gives me a 404 error saying that the URL /wp-content/themes/blank/images/body-bg.png was not found on the server.

    What am I doing wrong? And before you say anything, yes, the file path is correct, and yes, the file does exist in that folder. Help me!

    P.S. Also, I do not know if this makes a difference or not, but I am working locally on “localhost.” Thanks in advance!

    #62889
    clokey2k
    Participant

    You already know where the fault is – the source URL is incorrect. Not knowing your structure I can only make rough suggestions.

    If ‘style.css’ is in the theme folder and the image is in an ‘image’ folder in the theme folder then:

    body {background: url(./images/body-bg.png) top center repeat-x white}

    Should work.

    Google ‘Absolute URLs’ and ‘Relative URLs’ for more info.

    #62890
    mwdewitt
    Member

    That fixed it! Thank you so much! I knew something was wrong with the URL, but I am new to the syntax used in HTML and PHP. I thought I had to give a URL that linked all the way back to the “root” folder where the entire WordPress site is housed. It never occurred to me that all I needed to do was just reference to the “theme” folder. Thanks once again!

    P.S. I will be sure to read up on “absolute URLs” and “relative URLs.”

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Other’ is closed to new topics and replies.