Bender Bender - 3 months ago 17
CSS Question

What won't image go inside div?

I'm trying to put an image inside a div of the same dimension but for some reason the image keeps appearing to right of the div even though it's inside the div in my html:

<div>
<img width="16" height="16"></img>
</div>


I created a JSfiddle that shows what's going on: https://jsfiddle.net/5q0s3y1j/

Can anybody help me understand how to put the image inside the div?

Answer

The issue is with left: 20px; in your .userFlair css. It's telling the image to shift 20 pixels left from the start of the container, which is larger than the container itself.

Changing this to left: 0; or omitting it completely will put the image in the div.

Here's an updated fiddle.