Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply background image for an templates in django

In my site, in a table of particular I have to insert a image as background. I did that but the image looks like double image as the image is smaller than cell width and height it is getting overlap.

In background image cell I used no-repeat to end the repeat display of same image, but it is not working. I am designing web page using html in django framework.

template is

<td background="{{ STATIC_URL }}images/sample.JPG" no-repeat;> 

May I know how to cancel the repeat display of same background image in a table cell.

Thanks

like image 251
user2086641 Avatar asked Nov 29 '22 13:11

user2086641


2 Answers

Look how I did it: In the template I put the following line:

<body id="bg" style="background-image: url('{% static "images/33.jpg"%}')";>

And in the css:

#bg{
    background-size: 1800px 900px;
    background-repeat: no-repeat;
    background-position: top;
    background-attachment: fixed;
}

As a result I obtained a fixed background and with the proportions of the screen.

like image 88
Ferney Bermeo Ruiz Avatar answered Dec 06 '22 21:12

Ferney Bermeo Ruiz


'no-repeat' is not a valid html attribute. Why aren't you using the style attribute OR a proper css included file?

<td style="background: url('{{ STATIC_URL }}images/sample.JPG') no-repeat;"> 
like image 28
Hedde van der Heide Avatar answered Dec 06 '22 20:12

Hedde van der Heide