How to make the background image to fit into the whole page without repeating using plain css?

前端 未结 6 479
温柔的废话
温柔的废话 2021-02-01 06:28

I have an JPG image with size 1024 x 724. My page size is not fixed. My requirement is: If I resize the page then the background image should also resize and fit to the page.

6条回答
  •  庸人自扰
    2021-02-01 06:49

    You can't resize background images with CSS2.

    What you can do is have a container that resizes:

    []

    This way, the div will sit behind the page and take up the whole space, while resizing as needed. The img inside will automatically resize to fit the div.

提交回复
热议问题