使用HTML、CSS 和JavaScript 自訂懸停時的圖像外觀
處理懸停時的圖像過渡時,您可能會遇到常見問題是底層影像仍然可見,且更新後的影像無法調整到所需的高度和寬度,從而導致重疊。
在您的程式碼片段中:
<img src="/static/imghwm/default1.png" data-src="LibraryTransparent.png" class="lazy" alt="使用 CSS 或 JavaScript 更改懸停圖像時如何防止圖像重疊?" >
#Library { height: 70px; width: 120px; } #Library:hover { background-image: url('LibraryHoverTrans.png'); height: 70px; width: 120px; }
您更改背景圖像的嘗試是正確的。但是,要解決高度和寬度問題,您可以在 :hover 選擇器中使用以下 CSS 屬性:
#Library:hover { background-image: url('LibraryHoverTrans.png'); height: 70px; width: 120px; background-size: cover; }
background-size: cover 屬性可確保更新的圖片填滿整個空間元素,防止重疊。
或者,您可以使用 JavaScript 來處理映像轉換。這種方法可讓您直接變更影像的 src 屬性:
<img src="/static/imghwm/default1.png" data-src="LibraryTransparent.png" class="lazy" onmouseover="this." onmouseout="this." alt="使用 CSS 或 JavaScript 更改懸停圖像時如何防止圖像重疊?" >
以上是使用 CSS 或 JavaScript 更改懸停圖像時如何防止圖像重疊?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

是的,youshouldlearnbothflexboxandgrid.1)flexboxisidealforone-demensional,flexiblelayoutslikenavigationmenus.2)gridexcelstcelsintwo-dimensional,confffferDesignssignssuchasmagagazineLayouts.3)blosebothenHancesSunHanceSlineHancesLayOutflexibilitibilitibilitibilitibilityAnderibilitibilityAndresponScormentilial anderingStruction

重構自己的代碼看起來是什麼樣的?約翰·瑞亞(John Rhea)挑選了他寫的一個舊的CSS動畫,並介紹了優化它的思維過程。

CSSanimationsarenotinherentlyhardbutrequirepracticeandunderstandingofCSSpropertiesandtimingfunctions.1)Startwithsimpleanimationslikescalingabuttononhoverusingkeyframes.2)Useeasingfunctionslikecubic-bezierfornaturaleffects,suchasabounceanimation.3)For

@keyframesispopularduetoitsversatoryand and powerincreatingsmoothcsssanimations.keytricksinclude:1)definingsmoothtransitionsbetnestates,2)使用AnimatingMultatingMultationMultationProperPertiessimultane,3)使用使用4)使用BombingeNtibalibility,4)使用CombanningWiThjavoFofofofoftofofo

CSSCOUNTERSAREDOMANAGEAUTOMANAMBERINGINWEBDESIGNS.1)他們可以使用forterablesofcontents,ListItems,and customnumbering.2)AdvancedsincludenestednumberingSystems.3)挑戰挑戰InclassINCludeBrowsEccerCerceribaliblesibility andperformiballibility andperformissises.4)創造性

使用滾動陰影,尤其是對於移動設備,是克里斯以前涵蓋的一個微妙的UX。傑夫(Geoff)涵蓋了一種使用動畫限制屬性的新方法。這是另一種方式。


熱AI工具

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

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

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

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

熱門文章

熱工具

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

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

WebStorm Mac版
好用的JavaScript開發工具

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