CSS Background image on html image element?
by Pascal Opitz on September 15 2008, 07:01
My co-worker Paul showed how helpful it is to question the obvious: Can you apply a background image to an image?
And, as he found out, the answer is: Yes!
Switch the image to display: block, apply a padding, and there you go, you can set up backgrounds for images …
See the little demo I’ve built to achieve a paralax like scrolling with just a div and an img.
Comments
by icaaq on September 12 2008, 09:05 #
by Dave Child on September 12 2008, 06:00 #
by Martin Ivanov on September 15 2008, 06:31 #
img{
display:block;
padding:1px;
background:red;
border:1px solid black;
}
by icaaq on September 12 2008, 05:35 #
by Pascal Opitz on September 15 2008, 07:13 #
by Nisheeth on December 3 2008, 10:34 #
by kattykatty on December 20 2008, 16:13 #
by jamie on August 11 2010, 12:51 #
by Pascal Opitz on August 11 2010, 17:58 #