Stretch an image to fill width of browser window

前端 未结 5 1952
谎友^
谎友^ 2021-02-08 12:11

I have an image, and I want the width to fill up the browser window, no matter the size of the window.

How do I do this in HTML and CSS?

5条回答
  •  暖寄归人
    2021-02-08 12:16

    You can add a div with width an height of 100%, also set image's width and height are 100%

    ​​​​​​​​​​

    CSS:

    #wrapper, img{
        width:100%;
        height: 100%;
    }
    

    jsfiddle

提交回复
热议问题