How to put an image in div with CSS?

前端 未结 4 892
暗喜
暗喜 2020-11-28 20:05

I would like to have all my images in CSS (the only way I know how is to put them in as background images).

But the problem in this solution is you can never let the

4条回答
  •  甜味超标
    2020-11-28 20:36

    This answer by Jaap :

    and in CSS :

    div.image {
       content:url(http://placehold.it/350x150);
    }​
    

    you can try it on this link : http://jsfiddle.net/XAh2d/

    this is a link about css content http://css-tricks.com/css-content/

    This has been tested on Chrome, firefox and Safari. (I'm on a mac, so if someone has the result on IE, tell me to add it)

提交回复
热议问题