We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21940
    • 20 Posts
    In my old html layout I had images linked in my css code such as this background image below
    body {
    font: normal 62.5% Tahoma,sans-serif;
    background-image: url(../img/bg_image.png);
    background-color: #6c6c6c;
    background-repeat: repeat-x;
    }
    and this header image below
    .header {
    background: url(../img/logo_hdr.png) no-repeat center top;
    height: 358px;
    margin-bottom: 5px;
    }

    when I placed the css file into my template everything comes up except these images. I read that all you have to do is add "../" before the image location but it didn’t work for these images only the other 1 image that was in the css file.

    Any help would be great in helping me figure this one out.

    Thanks
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Background images in .css files are relative to the css file. So if you have a folder with your .css file and an img folder with your images, the path would be img/filename.jpg. If your .css file is in a folder named style, then you would need ../img/filename.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
        • 21940
        • 20 Posts
        I tried both ways and you can see in the code that I posted that I now have it with ../img/filename.jpg and it hasn’t worked that is why I posted the question on here since both ways don’t seem to work for me.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Well, without seeing your file structure it’s hard to be any more specific.

          Does your template have a <link rel="stylesheet" ... /> tag, or is this css in <style>...</style> tags in the template head?
            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
            • 21940
            • 20 Posts
            I have the template setup as such
            <link href="assets/templates/amdesigns/styles/master.css"rel="stylesheet" type="text/css"/>

            Here is the link http://www.amdesignsstudio.com/modx-1.0.0/

            and this is what it should look like http://www.amdesignsstudio.com

            Thank you
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Ok, so where are the images? assets/templates/amdesigns/images?

                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
                • 21940
                • 20 Posts
                assets/templates/amdesigns/img
                and the css is in
                assets/templates/amdesigns/styles
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  then
                  #whatever {
                      background: url(../img/image-name.jpg);
                  }
                  

                  will do the trick. Since the .css file is in amdesigns/styles, you need to go up one (../) into amdesigns, then back down into the img folder to get the image file.
                    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
                    • 21940
                    • 20 Posts
                    That is exactly what I thought it would be as well but it doesn’t work. That is the way I have it now
                    body {
                    font: normal 62.5% Tahoma,sans-serif;
                    background-image: url(../img/bg_image.png);
                    background-color: #6c6c6c;
                    background-repeat: repeat-x;
                    }
                      • 4041
                      • 788 Posts
                      I see in the source of the page this:

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

                      which should be:

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

                      Change that and see if it helps smiley
                        xforum
                        http://frsbuilders.net (under construction) forum for evolution