HTML, CSS – image inside image, how to do that?


I have this piece of HTML code:

    <image src="image-inside-pic-png.png" alt="">
  <image src="pic.png" alt="" />

The pic.png (300×300 px) is the main image. I would like to put the image-inside-pic-png.png (20×20 px) inside of it. When I apply position: absolute; on the small image, it works only momentarily.
If I change the size of either, it no longer works.

So my question is, how can I move the small image always in the big image – and this small image will be always 15px from the top and 30px from the right margin of the big image?

Thank you for help


Without changing your markup this can be achieved e.g. using display:inline-block to the outermost div element (so it won’t extend for 100% of the available width) and position relative + absolute for outermost div and thumbnail

see this fiddle:
border and image size are defined for simplicity

Answered By – Fabrizio Calderan

Answer Checked By – Jay B. (AngularFixing Admin)

Leave a Reply

Your email address will not be published.