Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

replacement for img tag

Tags:

html

css

How can I replace this tag:

<img src="images/username_t.png" />

to use CSS?

How can I show an image using CSS styles?

like image 443
Naor Avatar asked Dec 17 '22 10:12

Naor


1 Answers

Html:

<div id="pic"></div>

CSS:

#pic {
    background-image: url('images/username_t.png');
    width: 100px; /* image width */
    height: 100px; /* image height */
    display: inline-block; /* so that it behaves like the img element */
}

For css, there are a few options dealing with background images, so check these out as well:

background-attachment
background-image
background-position
background-repeat
background-clip
background-origin
background-size

like image 152
Shaz Avatar answered Dec 28 '22 23:12

Shaz