Background Image Scaling While Maintaining Aspect Ratio

前端 未结 4 1129
情歌与酒
情歌与酒 2020-12-08 20:19

I would like to have images for my background that change automatically like a slide show. But I would like the images to fill the background no matter what size the browse

4条回答
  •  死守一世寂寞
    2020-12-08 21:05

    You can not reliably resize background images across all browsers/versions etc...

    The effect you see on thesixtyone.com site is achieved by stretching a normal inline image to 100% of it's container which is a placeholder division. Other elements are then floated over the top of this 'background' division.

    So the answer is not to use a background image, but to make an image fill the screen in a placeholder, then put other elements on top of it.

提交回复
热议问题