使用 CSS 將超大圖像在 Div 中居中
使用 div 寬度變化的流體佈局時,將超大圖像在 div 中居中可能會具有挑戰性。影像可能從左邊緣開始,使其偏離中心到右側。
為了解決這個問題,我們提出了一個CSS 解決方案,可以有效地將圖像居中,在兩側邊緣創建均勻的溢出截止:
<code class="css">.parent { position: relative; overflow: hidden; } .child { position: absolute; top: -9999px; bottom: -9999px; left: -9999px; right: -9999px; margin: auto; }</code>
父div 建立相對定位並包含溢出。包含影像的子 div 具有絕對定位,具有極其負的頂部、底部、左側和右側值。這些負值有效地將影像推到 div 的可見區域之外。 margin: auto 屬性確保映像檔在父 div 內自動居中。
此技術可讓影像保持其原始寬高比,消除任何瀏覽器施加的可能會影響影像品質的調整大小問題。結果是一個居中的超大圖像,帶有溢出,兩側均勻裁剪。
以上是如何使用 CSS 將超大圖片置於 Div 中?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

重構自己的代碼看起來是什麼樣的?約翰·瑞亞(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
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

Atom編輯器mac版下載
最受歡迎的的開源編輯器

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

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

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

SublimeText3 Linux新版
SublimeText3 Linux最新版