How can I position an icon over an image or video?

You need a relative container around your image and then you set your icon to be position: absolute.

.container { position: relative; }
.container img { display: block; }
.container .fa-download { position: absolute; bottom:0; left:0; }
<link href="https://use.fontawesome.com/releases/v5.7.1/css/all.css" rel="stylesheet"/>

<div class="container">
   <img src="https://placekitten.com/300/300">
   <a href="https://stackoverflow.com/questions/54508374/dog.png" download="new-filename"><i class="fas fa-download"></i></a>
</div>

The reason why you need you img to be display: block is because, by default, img‘s are display: inline and your img will have a space between the bottom of it and the bottom of the container – so your download icon will appear slightly below your img. Setting it to display: block stops this.

Leave a Comment