We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2642
    • 4 Posts
    I have use Andreas 08 for firepro-id.com, and I want to put background images on header, How to put the code in css or in template (what about multiple background). I just little know about css and html.

    I have use modx for 3 my company website www.technotama.com and www.tsmfire.com and www.firepro-id.com.
    Just using existing template, if you have any sugestion for thank you.

    Bravo MODX

    Yusuf
    Jakarta
      • 31037
      • 358 Posts
      Hi, I’m just learning css, but if I add this to your css I can see the background picture:

      #header {
      background-image: url(assets/templates/andreas08/images/bg_head.jpg);
      background-repeat: no-repeat;
      }

      Your backgrond picture also have different size than the header div, don’t know if it is important, but I would correct this.

      Not much help, I know, but at least an answer! I’m a css newbie! smiley
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        The easiest way to do a background image is:
        background: #ffffff url(path-to-background-image) top left no-repeat;
        

        The color (#ffffff) should be a nice color in case something happens to the image. The path to the image depends on where the CSS is; if it’s a CSS file in assets/templates/yourtemplate/yourcssfile.css, and the images are in assets/templates/yourtemplate/images, then the path would just be url(images/mybgimage.png). If you are using a snippet or TV to make the background dynamic, then it would be url(assets/templates/mytemplate/images/myimage.png).

        You can make a dynamic background image by using a TV to hold the image filename, then in the template head have a brief style block:
        <style type="text/css">
        #banner{
        background:#ffffff url(assets/templates/mytemplate/images/[*bannerbg*]) top left no-repeat;
        }
        </style>
        

        Then make a simple TV named bannerbg with a text input type, and in the TV for each page you can just specify the filename you want. It’s handy to use @INHERIT in the TV default, then you can just specity the filename for each folder/document in your document tree, and its children will inherit that image.

        I’ve done something similar, only I used a snippet instead of a TV, and it pulled a random image from the assets/templates/mytemplate/images folder. So every page got a random background image.

        Why a snippet instead of a TV? A TV gets an editing field on each document editing page. If I don’t need to be editing the value, a snippet is more suitable.
          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