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

后端 未结 22 2669
迷失自我
迷失自我 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 02:08

    I use this, and it works with all browsers:

    
        
            Stretched Background Image
            
            
            
        
        
            
    Smile

    Stretch that Background Image!

    This text appears in front of the background image. This is because we've used CSS to layer the content in front of the background image. The background image will stretch to fit your browser window. You can see the image grow and shrink as you resize your browser.

    Go on, try it - resize your browser!

提交回复
热议问题