How do I stretch a background image to cover the entire HTML element?

后端 未结 13 1133
难免孤独
难免孤独 2020-12-04 09:02

I\'m trying to get a background image of a HTML element (body, div, etc.) to stretch its entire width and height.

Not having much luck. Is it even possible or do I h

13条回答
  •  渐次进展
    2020-12-04 09:18

    You cannot in pure CSS. Having an image covering the whole page behind all other components is probably your best bet (looks like that's the solution given above). Anyway, chances are it will look awful anyway. I would try either an image big enough to cover most screen resolutions (say up to 1600x1200, above it is scarcer), to limit the width of the page, or just to use an image that tile.

提交回复
热议问题