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

后端 未结 13 1177
难免孤独
难免孤独 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:30

    Not sure that stretching a background image is possible. If you find that it's not possible, or not reliable in all of your target browsers, you could try using a stretched img tag with z-index set lower, and position set to absolute so that other content appears on top of it.

    Let us know what you end up doing.

    Edit: What I suggested is basically what's in gabriel's link. So try that :)

提交回复
热议问题