Making an image width:100% inside a inline-block element

后端 未结 3 1667
孤街浪徒
孤街浪徒 2021-01-22 04:56

If I have an image on a page with width set to 100% in css it is as wide as the browser. Fine. However, if I make a containing div have display:inline-block, then the image is n

3条回答
  •  再見小時候
    2021-01-22 05:47

    I dont think this will help your problem , but technically you could do it by giving it position:absolute;

        img {
            width:100%;
        }
    
        div img {
            position:absolute;
            margin:0 auto;
            width:100% !important;
        }
    

    http://jsfiddle.net/kjf8s3rq/

提交回复
热议问题