ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How to get background images to show.

November 15, 2009 8:03am

Subscribe [3]
  • #1 / Nov 15, 2009 8:03am

    marsh

    8 posts

    How do I get background images to show. I’ve used this

    {site_url}images/photo.gif
    to display images, but can’t get background images using this
    background-image: url(images/photo.gif) no-repeat top left;
    nor this
    background-image: "{site_url}(images/photo.gif)" no-repeat right bottom

    I guess I’m doing something wrong but don’t know what. Please help

  • #2 / Nov 15, 2009 9:09am

    Herb

    224 posts

    I’ll assume you are doing this within a cascading style sheet with something like this:

    body {background-image: url(images/photo.gif) no-repeat top left;}

    Make sure your path to the image is correct.  The path you have places the images folder immediately off the root so it would be located at:

    <a href="http://www.yoursite.com/images/photo.gif">http://www.yoursite.com/images/photo.gif</a>

    And if you were to type the above directly into your address bar on your browser, do you get the image?

    Or you can try it like this:

    {background: url(images/photo.gif) no-repeat top left;}
  • #3 / Nov 15, 2009 5:12pm

    Roi Agneta

    352 posts

    I guess I’m doing something wrong but don’t know what. Please help

    Couple of things that are wrong:

    If you use the background-image rule, you are limited to specifying the url ONLY, no positioning or repeats.  You should use this instead (note position of brackets and quotes):

    .classname/element_name {background:url('{site_url}images/image_name.png') right bottom no-repeat;}
  • #4 / Nov 16, 2009 1:36pm

    marsh

    8 posts

    Thank you. I’ve tried both suggestions, still image won’t show. Path to the image is correct as per

    <a href="http://www.yoursite.com/images/photo.gif">http://www.yoursite.com/images/photo.gif</a>

    I’ve tried it in a browser and image displays, yet won’t show up when I reference it in the css. I have my css as a template in EE.

  • #5 / Nov 16, 2009 3:23pm

    Roi Agneta

    352 posts

    Can you send a link to the actual page?

  • #6 / Nov 17, 2009 8:44am

    marsh

    8 posts

    Thanks a lot. Your suggestion did it for me eventually.

  • #7 / Nov 17, 2009 3:02pm

    Roi Agneta

    352 posts

    Great, glad to be of help!

  • #8 / Jan 23, 2010 1:26pm

    Jose B

    313 posts

    Thanks for your answe Roi.Agneta.  I tried a variation of it on my CSS as follows and it worked.

    body{
        font-family: Arial,sans-serif;
        color: #333333;
        line-height: 1.166;    
        margin: 0px;
        padding: 0px;
        background:url('{site_url}images/uploads/3scp_78.jpg') no-repeat fixed left top;
    }
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases