如何創建高度不同但寬度一致的 CSS 圖像疊加?
圖片上的CSS 疊加:綜合指南
簡介
簡介
建立影像疊加層為了實現這種效果,我們將使用 div 容器來保存影像和覆蓋內容。以下CSS 規則將建立疊加層:
.image-container { position: relative; width: 200px; } .image-container .after { position: absolute; top: 0; left: 0; width: 100%; display: none; color: #FFF; } .image-container:hover .after { display: block; background: rgba(0, 0, 0, .6); }
登入後複製
HTML 結構
HTML 結構將包含影像和疊加層內容:<div class="image-container"> <img src="image.jpg"> <div class="after">This is some content</div> </div>
登入後複製
增強疊加層
.image-container .after .content { position: absolute; bottom: 0; text-align: center; width: 100%; padding: 5px; }
登入後複製
這將垂直對齊底部的覆蓋內容。
自訂演示.image-container { position: relative; display: inline-block; } .image-container img { display: block; } .image-container .after { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: none; color: #FFF; } .image-container:hover .after { display: block; background: rgba(0, 0, 0, .6); } .image-container .after .content { position: absolute; bottom: 0; font-family: Arial; text-align: center; width: 100%; box-sizing: border-box; padding: 5px; } .image-container .after .zoom { color: #DDD; font-size: 48px; position: absolute; top: 50%; left: 50%; margin: -30px 0 0 -19px; height: 50px; width: 45px; cursor: pointer; } .image-container .after .zoom:hover { color: #FFF; }
登入後複製
<div class="image-container"> <img src="image.jpg"> <div class="after"> <span class="content">This is some content. It can be long and span several lines.</span> <span class="zoom"><i class="fa fa-search"></i></span> </div> </div>
登入後複製
以上是如何創建高度不同但寬度一致的 CSS 圖像疊加?的詳細內容。更多資訊請關注PHP中文網其他相關文章!
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章
如何修復KB5055612無法在Windows 10中安裝?
4 週前
By DDD
<🎜>:泡泡膠模擬器無窮大 - 如何獲取和使用皇家鑰匙
4 週前
By 尊渡假赌尊渡假赌尊渡假赌
<🎜>:種植花園 - 完整的突變指南
3 週前
By DDD
北端:融合系統,解釋
4 週前
By 尊渡假赌尊渡假赌尊渡假赌
Mandragora:巫婆樹的耳語 - 如何解鎖抓鉤
3 週前
By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

在本週的平台新聞綜述中,Chrome引入了一個用於加載的新屬性,Web開發人員的可訪問性規範以及BBC Move

有很多分析平台可幫助您跟踪網站上的訪問者和使用數據。也許最著名的是Google Analytics(廣泛使用)
