If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!

Wanting to use a background image for my app !

I put in my layout layout file the following declaration just before the closing head tag ( .. </head> )

 

<style type="text/css">
    body{
    background-image:url('images/pattern.png');
    font-family: 'Ubuntu', arial, sans-serif;
    }
</style>

 

For some reason ..... it is not showing up ... I even tried to put it directly the css file ... it still does not show up as background.

I also tried writing it like this : background-image: URL('static','images/pattern.png'); it still does not work !

the "pattern.png" is well inside the images folder in the static folder of my app !

Can someone please tell me ... how come it is not working .. and how can I make my background image showing up as background image ( repeat xy should be considered by default  so it was not specified ...) even when it is specified .. nothing shows up !

 

Please help .. please assist ...

 

I am sure this should be simple ! .. but it is not working !

 

Answers (2)

Comments (2)

  • Login to post



  • 0
    anthony 12 years ago

    If the image is in the application's static folder, then the proper URL would be /yourapp/static/images/pattern.png. The URL you are using ("images/pattern.png") is a relative URL, so the browser will just add it to the URL of the current page, which obviously isn't correct. If you want to use the web2py URL() function to write the URL (good idea), then you have to put the code inside the web2py template delimiters, since it is Python code and not HTML/CSS:

    background-image: url("{{=URL('static','images/pattern.png')}}");
    replies (4)
    • anthony 12 years ago

      Regarding your question about dynamically changing the header, I think I answered that on the Google Group: https://groups.google.com/d/msg/web2py/8993F3GVxDQ/06U2BKF4vkYJ.

    • anthony 12 years ago

      Sorry, forgot to wrap the generated URL inside url() -- I edited the answer with this correction.

    • don-clermont-10094 12 years ago

      Anthony my friend ! - thank you for the update ... I found a way to make it happen !! .. finally ... I simply had to stick it in the web2py.css file, around line 37, at the definition of html, body{ .... }

      now that I got this to work ... next to my other problem .. it has to do with the alternate header, when a user is logged in ... with its own navmenu, depending on what the usertype is or what group does he belong to ... but first ... I am trying to figure out how to set the following condition in web2py --- > if the user is logged in ? then do {include this header2 with menu2 } else do { include that header1 with menu1}

      do you have any suggestion for me .. ???

    • don-clermont-10094 12 years ago

      Thank you .. Anthony, ... After I read your suggestion .. I thought that it would work ... but ... It still does not work !! ??? ... This is what how I put it before the closing head tag : ...... <style type="text/css"> body{ background-image:{{=URL('static','images/pattern.png')}}; font-family: 'Ubuntu', arial, sans-serif; } </style>

      </head>

      any other ideas ?? ...

      thank you


  • 0
    ritika-sharma-11660 10 years ago

    i also faced the sameproblem...................the real problem is url gets the value say with %29 appended at the end

    bac

Related content


Hosting graciously provided by:
Python Anywhere