簡體   English   中英

我有一個 APNG,我正在嘗試將其設置為我的背景圖像,但圖像並沒有完全覆蓋整個背景

[英]I have an APNG and I'm trying to set it as my background image, but the image does not cover the whole background fully

我有一個試圖設置為背景的 APNG。 我正在使用屬性 [ background-image: URL('APNG.png') ]。 但是,它的尺寸與屏幕 window 的尺寸不完全匹配。 因此,圖像最終會變得非常小,或者最終會變得太大並被剪裁。 如何設置背景圖像以覆蓋整個背景。 我對被拉伸的圖像很好。 我只需要它隨時填充背景而無需重復。

謝謝你的幫助。 斯里拉姆

將 CSS background-size屬性與您的background-image一起使用。 下面的例子:

 #example { width: 200px; height: 200px; border: 2px solid black; /* the original image has a size of: 100x100 */ background-image: url('https://upload.wikimedia.org/wikipedia/commons/1/14/Animated_PNG_example_bouncing_beach_ball.png'); background-size: 100%; /* or use "contain|cover|auto|....." */ }
 <div id="example"></div>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM