Stretch and scale CSS background

前端 未结 16 2286
难免孤独
难免孤独 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:07

    Add a background-attachment line:

    #background {
        background-attachment:fixed;
        width: 100%; 
        height: 100%; 
        position: absolute; 
        margin-left: 0px; 
        margin-top: 0px; 
        z-index: 0;
    }
    
    .stretch {
        width:100%;
        height:auto;
    }
    

提交回复
热议问题