+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Background image on div (using an inline style) not appearing

Background image on div (using an inline style) not appearing

3 posts, 0 answered
  1. Diana
    Diana avatar
    16 posts
    Registered:
    26 Nov 2008
    07 Jan 2009
    Link to this post

    I can't seem to get a background image on a div using an inline style in a masterpage created for Sitefinity.  In Visual Studio, when looking at the masterpage in the design view the image appears, yet once it is loaded into Sitefinity, the image doesn't appear in the template.  When I move the style to the css it works fine, but since I need to set the url of the image progammatically, I think I need the inline style.

    Example: When I put the following example into my masterpage, the height is applied, but the image is not.

    <div id="test" style="height:330pxbackground:url(../Images/header_home.jpg) no-repeat 0px 0px;">

     

     

    </div>

    Thanks for any help you might be able to provide,
    Diana

     

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    08 Jan 2009
    Link to this post
    Hi Diana,

    It seems that there is a typo. After the round brackets you should have semi-colon as below;

    <div id="test" style="height:330px; background:url(../Images/MyPicHere.gif); no-repeat 0px 0px;"

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Diana
    Diana avatar
    16 posts
    Registered:
    26 Nov 2008
    09 Jan 2009
    Link to this post
    Hi Ivan,
    Thanks for your reply.  I tried what you said, but it still didn't work (Even though I believe the semi-colon goes after the all of the background attributes and not just after the url(). 

    But .. I have just figured it out - its the problem of using relative paths in the master pages. It works when I use (images/image.jpg) but not (../images/image.jpg) nor (~/images/image.jpg) since I just realized that the page is generated at the same level as the images folder.

    Thanks again for your help and sorry for wasting your time!
    Diana
Register for webinar
3 posts, 0 answered