Can't resize image using CSS

后端 未结 5 1411
萌比男神i
萌比男神i 2021-01-01 03:36

I\'ve tried every answer I could find on all the sites I could find, but still haven\'t been able to properly resize an image using CSS. I\'ve got it inside a div, and tried

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-01 04:19

    You have to give the id banner a specific width that is less than 100%. You don't need a height, it already is automatic. You have to target the image inside the banner and not the class added to the image. So it should look like this:

    
    
    #banner{
        width: 60%;
        left: 0px;
        right: 0px;
    }
    
    #banner img{
        width: 100%;
        left: 0px;
        right: 0px;
    }
    

提交回复
热议问题