下面為大家帶來一篇CSS background全部總結。內容還挺不錯的,現在就分享給大家,也給大家做個參考。
所有背景屬性都不能繼承。
1. background-color
所有元素都能設定背景顏色。
background-color的預設值是transparent;也就是說,如果一個元素沒有指定背景顏色,那麼背景就是透明的,這樣其祖先元素的背景才能可見。
2. background-image
所有元素都能設定背景圖像;
背景圖像可以設定多個,中間用逗號隔開;背景影像會層疊,寫在前面的層次在上面。
3. background-repeat
repeat(預設)/no-repeat/repeat-x/ repeat-y
##4. background-attachment
scroll(預設)/fixed
5. background-position
6. background-size
設定背景圖片的尺寸;預設值為auto。 像素法:第一個值設定寬度,第二個值設定高度;若只有一個值,第二個值為auto。 百分比法:以父元素的寬度和高度以基準來計算。 關鍵字cover,不改變影像寬高比例,在水平和垂直方向都鋪滿整個元素,有可能導致一部分影像溢出。 關鍵字contain,不改變影像寬高比例,盡可能拉伸,直到某一方向鋪滿整個元素,有可能導致另一方向沒有鋪滿。7. background-origin
定義背景圖片的初始位置border-box,邊框左上角。 padding-box,padding區域左上角;預設值。 content-box,內容區左上角。8. background-clip
The CSS3 background-clip property specifies the painting area of the background.The property takes three different values: •border-box - (default) the background is painted to the outside edge of the border•padding-box - the background is painted to the outside edge of the padding•content-box - the background is painted within the content box(英文的解釋得比較清楚)(英文都是從W3Schools Online搬運)
關於background-origin和background-clip,它們是互相獨立的,互不干擾。
關於background的CSS寫法,個人認為應該邏輯明確、層次分明;具體而言:
background定義背景圖像,background- color定義背景顏色,background-clip定義背景顯示區域。
(個人見解,僅供參考)Full Size Background ImageIf we want to have a background image on a website that covers the entire browser window at all times.The requirements are as follows:• Fill the entire page with the image (no white space)
• Scale image as needed
• Center image on page
• Do not cause scrollbars
The following example shows how to do it; Use the html element (the html element is always at least the height of the browser window). Then set a fixed and centered background on it. Then adjust its size with the back-size propertyd #html { background: url(img_flower.jpg) no-repeat center fixed; background-size: cover; }
小tips:利用背景影像的水平平鋪,實現波浪式的邊框效果。
(目前只有想法,還沒找到符合需求的圖像。)
以上就是本文的全部內容,希望對大家的學習有所幫助,更多相關內容請關注PHP中文網!
相關推薦:
關於CSS3開啟硬體加速的使用與陷阱關於CSS程式碼如何書寫規格#
以上是關於CSS background的使用方法的詳細內容。更多資訊請關注PHP中文網其他相關文章!

鏈接CSS文件到HTML可以通過在HTML的部分使用元素實現。 1)使用標籤鏈接本地CSS文件。 2)多個CSS文件可通過添加多個標籤實現。 3)外部CSS文件使用絕對URL鏈接,如。 4)確保正確使用文件路徑和CSS文件加載順序,優化性能可使用CSS預處理器合併文件。

選擇Flexbox還是Grid取決於佈局需求:1)Flexbox適用於一維佈局,如導航欄;2)Grid適合二維佈局,如雜誌式佈局。兩者在項目中可結合使用,提升佈局效果。

包含CSS文件的最佳方法是使用標籤在HTML的部分引入外部CSS文件。 1.使用標籤引入外部CSS文件,如。 2.對於小型調整,可以使用內聯CSS,但應謹慎使用。 3.大型項目可使用CSS預處理器如Sass或Less,通過@import導入其他CSS文件。 4.為了性能,應合併CSS文件並使用CDN,同時使用工具如CSSNano進行壓縮。

是的,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)創造性


熱AI工具

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

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

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

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

熱門文章

熱工具

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

Dreamweaver CS6
視覺化網頁開發工具

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