Stretch and scale a CSS image in the background - with CSS only

后端 未结 22 2651
迷失自我
迷失自我 2020-11-22 01:37

I want that my background image stretch and scale depending on the browser viewport size.

I\'ve seen some questions on Stack Overflow that do the job, like

22条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 01:58

    You can actually achieve the same effect as a background image with the img tag. You just have to set its z-index lower than everything else, set position:absolute and use a transparent background for every box in the foreground.

提交回复
热议问题