CSS Multi-background屬性用於一次添加一個或多個圖像,不需要HTML代碼,我們可以根據需要添加圖像;
#multibackground { background-image: url(/css/images/logo.png), url(/css/images/border.png); background-position: left top, left top; background-repeat: no-repeat, repeat; padding: 75px; }
最常用的值如下所示;
Sr.No. | Value & Description |
---|---|
1 | 背景 用於在一個區域中設置所有背景圖像屬性 |
2 | 背景剪輯 用於聲明背景的繪畫區域 |
3 | 背景圖像 用於指定背景圖像 |
4 | 背景原點 用於指定背景圖像的位置 |
5 | 背景大小 用於指定背景圖像的大小 |
Example
下面是演示多背景圖像的示例。
<html> <head> <style> #multibackground { background-image: url(/css/images/logo.png), url(/css/images/border.png); background-position: left top, left top; background-repeat: no-repeat, repeat; padding: 75px; } </style> </head> <body> <div id = "multibackground"> <h1>www.tutorialspoint.com</h1> <p> Tutorials Point originated from the idea that there exists a class of readers who respond better to online content and prefer to learn new skills at their own pace from the comforts of their drawing rooms. The journey commenced with a single tutorial on HTML in 2006 and elated by the response it generated, we worked our way to adding fresh tutorials to our repository which now proudly flaunts a wealth of tutorials and allied articles on topics ranging from programming languages to web designing to academics and much more.. </p> </div> </body> </html>
它將產生以下結果&負;
Size of Multi background
多背景屬性可以爲不同的圖像添加不同的大小;
#multibackground { background: url(/css/imalges/logo.png) left top no-repeat, url(/css/images/boarder.png) right bottom no-repeat, url(/css/images/css.gif) left top repeat; background-size: 50px, 130px, auto; }
如上所示,每個圖像具有特定的大小,如50px、130px和自動大小。