DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> CSS入門知識 >> CSS詳解
CSS3 教學(5):網頁背景圖片大小與多重背景
編輯:CSS詳解     

CSS3 的背景圖片大小可寫成 background-size:Apx Bpx;,其中:

-Apx = x 軸(圖片寬度)
-Bpx = y 軸(圖片高度)

了解這個原理後,我們就來實際體驗這個特性吧!當時對 CSS3 背景大小支援最好的是 Safari 與 Opera,因此我們只需使用 -o 與 -webkit 前綴。

背景大小

#backgroundSize{ border: 5px solid #bd9ec4; background:url(image_1.extention) bottom right no-repeat; -o-background-size: 150px 250px; -webkit-background-size: 150px 250px; padding: 15px 25px; height: inherit; width: 590px; }

瀏覽器支援:

  • Firefox(3.05+…)不支援
  • Google Chrome(1.0.154+…)支援
  • Google Chrome(2.0.156+…)支援
  • Internet Explorer(IE7、IE8 RC1)不支援
  • Opera(9.6+…)支援
  • Safari(3.2.1+ Windows…)支援

要在 CSS3 中套用多重背景圖片,我們以逗號分隔各組設定,例如:

background: url(image_1.extention) top right no-repeat, url(image_2.extention) bottom right no-repeat;

也就是說,我們可以在同一段程式碼中放置多張不同的背景圖……

多重背景圖

#backgroundMultiple{ border: 5px solid #9e9aab; background:url(image_1.extention) top left no-repeat, url(image_2.extention) bottom left no-repeat, url(image_3.extention) bottom right no-repeat; padding: 15px 25px; height: inherit; width: 590px; }

瀏覽器支援:

  • Firefox(3.05+…)不支援
  • Google Chrome(1.0.154+…)支援
  • Google Chrome(2.0.156+…)支援
  • Internet Explorer(IE7、IE8 RC1)不支援
  • Opera(9.6+…)不支援
  • Safari(3.2.1+ Windows…)支援
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved