Stretch Image to Fit 100% of Div Height and Width

前端 未结 4 974
余生分开走
余生分开走 2020-12-10 01:11

I have a div with the following CSS

#mydiv{
    top: 50px;
    left: 50px;
    width: 200px;
    height: 200px;
}

and my HTML looks like th

4条回答
  •  无人及你
    2020-12-10 01:53

    You're mixing notations. It should be:

    
    

    (note, no px). Or:

    
    

    (using the style attribute) The style attribute could be replaced with the following CSS:

    #mydiv img {
        width: 200px;
        height: 200px;
    }
    

    or

    #mydiv img {
        width: 100%;
        height: 100%;
    }
    

提交回复
热议问题