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

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

    It works for me

    .page-bg {
      background: url("res://background");
      background-position: center center;
      background-repeat: no-repeat;
      background-size: 100% 100%;
    }
    

提交回复
热议问题