We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24622
    • 12 Posts
    I’m new to ModX and using the CSS as documents and I can get everything to work except for the background images in the CSS document. No matter what I enter as the URL it will not display the images. I created a folder in the root and assets directories that contain my images.

    First I used backgound: url(assets/css/mycss/image.jpg) but no go.

    I also used url(css/mycss/image.jpg) and such.

    This is driving me up the wall. I search the forum and couldn’t find anything on this. What am I doing wrong?
      Just because I don't know what I'm doing, it has never stopped my from breaking something.
      • 21257 MODX Staff
      • 730 Posts
      Hi rcpettit,
      Is the CSS document you’re referencing in the root level of your site?
      Images in CSS are always referenced relative to the CSS document itself, not the document that uses the CSS file.
        Mike Schell
        Lead Developer, MODX Cloud
        Email: [email protected]
        GitHub: https://github.com/netProphET/
        Twitter: @mkschell
        • 24622
        • 12 Posts
        I followed the file structure that the CSS as document instructions said to use.

        assets/css/mycss but this didn’t works so i made a

        css/mycss in the modx root directory but still no luck.

          Just because I don't know what I'm doing, it has never stopped my from breaking something.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Try
          url([(base_url)]assets/css/mycss/image.jpg
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 24622
            • 12 Posts
            I tried that but it didn’t work. I also tried

            in the template:

            <base href="[(site_url)]" />

            and in the css document I used

            #header {
            background: url([(site_url)]/css/mycss/image.jpg)
            }



            But that didn’t work either.
              Just because I don&#39;t know what I&#39;m doing, it has never stopped my from breaking something.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Look in the page source and make sure that the URL being generated is the one you want. Can you provide a link?
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 24622
                • 12 Posts
                Sorry took so long to get back. Fixed the problem by reinstalling modx. Now everything works fine.
                  Just because I don&#39;t know what I&#39;m doing, it has never stopped my from breaking something.