Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2008
    Posts
    59
    Plugin Contributions
    0

    Default Trying to add a background image to main page

    Hi,

    I want to add a background image to a table placed on the main page via the define pages editor, but I seem to be having problems with the syntax (could be my CSS, which is a bit shaky).

    Code is


    Code:
    <table width="550" border="0" cellspacing="0" cellpadding="0" class=".mainPageImage">
      <tr>
        <td colspan="2" width="350"</td>
        <td width="250">Fantastic imported chocolate right here in Hong Kong Chocolate for health Loren Ipsum wibbleChocolate for health Loren Ipsum wibbleChocolate for health Loren Ipsum wibbleChocolate for health Loren Ipsum wibbleChocolate for health Loren Ipsum wibbleChocolate for health Loren Ipsum wibbleChocolate for health Loren Ipsum wibbleChocolate for health Loren Ipsum wibbleChocolate for health Loren Ipsum wibbleChocolate for health Loren Ipsum wibbleChocolate for health Loren Ipsum wibble</td>
      </tr>
    </table>
    and I've placed the following at the bottom of the main stylesheet

    Code:
    .mainPageImage  {
    background-color: blue;
    background-image: url(<?php echo '<img src="' . HTTP_SERVER . DIR_WS_CATALOG . 'images/orange/main_page_chocolate_bar.jpg" alt="chocolate" width="170">' ?>); 
    background-repeat: no-repeat;"
    
    }
    It's not throwing an error, just not showing any background. Note I wanted to do it like this as I want to position some text over the top of a graphic (using text for better SEO), so if anyone has a better solution would be happy to try another method.

    Cheers,
    Adam.

  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Trying to add a background image to main page

    class=".mainPageImage">

    needs to be

    class="mainPageImage">

    The dot is only used in the stylesheet to indicate a class, just as the # is only used in the stylesheet to indicate an id.

    Also, you can't use PHP in a stylesheet:
    Code:
    background-image: url(<?php echo '<img src="' . HTTP_SERVER . DIR_WS_CATALOG . 'images/orange/main_page_chocolate_bar.jpg" alt="chocolate" width="170">' ?>);
    You should use a relative url instead:
    Code:
    background-image: url(../images/orange/main_page_chocolate_bar.jpg);
    width: 170px;
    and the image (which is part of the template) should be saved in /includes/templates/your_template/images/, not the basic /images/ folder which is for products.
    Last edited by gjh42; 11 Sep 2008 at 05:29 AM.

  3. #3
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Trying to add a background image to main page

    If you want the element to be 250px wide, eliminate any mention of 170px. Just make the image itself that wide. CSS can't change the display size of an image, only the size of frame for it to be displayed in.

  4. #4
    Join Date
    Jul 2008
    Posts
    59
    Plugin Contributions
    0

    Default Re: Trying to add a background image to main page

    Doh! Should have spotted that - thanks for the quick reply, Glenn.

    Now I have another problem (albeit more minor)...I can get the image to display without a problem using an absolute address

    Code:
    .mainPageImage  {
    background-image: url(http://localhost/chococielo/zen-cart/images/orange/main_page_chocolate_bar.jpg); 
    background-repeat: no-repeat;"
    
    }
    but it doesn't work if I try to use PHP to call the image

    Code:
    background-image: url(<?php echo '<img src="' . HTTP_SERVER . DIR_WS_CATALOG . 'images/orange/main_page_chocolate_bar.jpg" alt="chocolate" width="170">' ?>);
    Any idea's???

    Cheers,
    Adam.

  5. #5
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Trying to add a background image to main page

    You can't use PHP there.

    Read the rest of my post above.

  6. #6
    Join Date
    Jul 2008
    Posts
    59
    Plugin Contributions
    0

    Default Re: Trying to add a background image to main page

    Sorry, in my haste I'd completely missed the second bit, will try the relative path you've recommended - many thanks again.

 

 

Similar Threads

  1. Help needed trying to add more than one image to the background of my store.
    By drgr33n in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 6 Oct 2010, 12:28 AM
  2. Background Colour/Image Main Page
    By gee38l in forum Templates, Stylesheets, Page Layout
    Replies: 11
    Last Post: 9 Jan 2009, 03:25 PM
  3. Background image on main page
    By johnagr in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 23 Aug 2008, 01:49 AM
  4. Background image on main page
    By JHouston in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 12 Mar 2008, 08:24 PM
  5. Main page background image problem!
    By tsaurus in forum Templates, Stylesheets, Page Layout
    Replies: 16
    Last Post: 1 Oct 2006, 03:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR