首頁  >  文章  >  web前端  >  如何使用 CSS 在圖像或影片上放置圖示?

如何使用 CSS 在圖像或影片上放置圖示?

Linda Hamilton
Linda Hamilton原創
2024-10-25 04:33:02766瀏覽

How to Position Icons Over Images or Videos Using CSS?

在影像或影片上放置圖示

要將圖示放置在影像或影片上,請在影像周圍建立相對容器並設定圖示的絕對位置就足夠了。

程式碼:

<code class="css">.container {
  position: relative;
}

.container img {
  display: block;
}

.container .fa-download {
  position: absolute;
  bottom: 0;
  left: 0;
}</code>

HTML:

<code class="html"><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="dog.png" download="new-filename"><i class="fas fa-download"></i></a>
</div></code>

此方法也與Bootstrap 3 相容。要使用 FontAwesome 下載圖示在左下角新增按鈕,只需新增以下程式碼:

以上是如何使用 CSS 在圖像或影片上放置圖示?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn