How do you stretch the background image

I have a gradient background that I use, as shown in the ASP.Net Webforms application:

<div style="background-image: url(foo.jpg) repeat-x;">
    ... Injected HTML codes
</div>

Where foo.jpg is a 200x1 image. My problem is that the height of the entered HTML varies from 200px to 1000 + px depending on the size of the datagrid. In addition, this segment is part of a much larger page that is used to host content.

What I would like is that after the HTML has been entered, the focus automatically stretches to fit the space so that the gradient smoothly applies over the entire height.

+3
source share
3 answers

CSS cannot stretch background images.

IMG , IMG , CSS, position: absolute z-index:-1, jQuery, .

+5

, SLaks "", . , , , 100% CSS. , , .

, . ,

<div style="background-image: url(foo.jpg) repeat-x;">
... Injected HTML codes
</div>

foo.jpg - 600px x 1px , -. , . , , - , . , , 300 . 300 600 . "" . , , .

,

<div style="background-image: url(foo.jpg) repeat-x;">
    <div  style="background-image: url(fooBottom.png) repeat-x; background-position: bottom;"
       ... Injected HTML codes
    </div>
</div>

fooBottom.png - 200 1 , 100% 100% .

"background-position: bottom"; . > 800 , .

800 , , . , "" . , , .

- , .

, . , .


UPDATE - http://sntsoftware.com/Blog

+1

, . ( cookie), , cookie ( Javascript) (. getViewportDimensions ). , CSS. . , Javascript cookie.

0

Source: https://habr.com/ru/post/1720822/


All Articles