CSS URL Helper

15 views
Skip to first unread message

F.C.

unread,
May 24, 2020, 12:18:15 AM5/24/20
to web2py-users
How do I use the URL helper in a CSS stylesheet that I reference in the landing page.

The CSS example that I have to add a background is the following:

/*header style*/
.header{
 background-image: url('../images/headerback.jpg');
 background-attachment: fixed;
 background-size: cover;
 background-position: center;
}

Can I use the URL helper here? I store my css code in a seperate file

Annet

unread,
May 24, 2020, 3:31:07 AM5/24/20
to web2py-users
When you store the css code in a view e.g. css.html and
include it in a view you can do:

background-image: url('{{=URL('static','images/headerback.jpg')}}');


An other option is the following:

<div class="header" style="background-image: url('{{=URL('static','images/headerback.jpg')}}'); background-repeat: no-repeat; background-size: cover; background-position: center center;">
  <div class="overlay">
  </div>
</div>


Kind regards,

Annet
Reply all
Reply to author
Forward
0 new messages