Stretch and scale CSS background

前端 未结 16 2302
难免孤独
难免孤独 2020-11-22 02:28

Is there a way to get a background in CSS to stretch or scale to fill its container?

16条回答
  •  情书的邮戳
    2020-11-22 03:00

    An additional tip for SolidSmile's cheat is to scale (the proportionate re-sizing) by setting a width and using auto for height.

    Ex:

    #background {
        width: 500px;
        height: auto;
        position: absolute; 
        left: 0px; 
        top: 0px; 
        z-index: 0;
    }
    

提交回复
热议问题