background-origin是CSS中定義的屬性,可幫助調整網頁的背景圖像。此屬性用於在背景中設置圖像的原點。默認情況下,此屬性將背景圖像原點設置為屏幕/網頁的左上角。
用法:
background-origin:padding-box|border-box|content-box|initial| inherit;
屬性值:
initial:這采用將背景原點設置為左上角的填充邊的初始值/默認值。
- 用法:
background-origin:initial;
- Example:
<!DOCTYPE html> <html> <head> <title>background-origin property</title> <style> .gfg { padding:40px; width:400px; background-image: url('https://media.geeksforgeeks.org/wp-content/cdn-uploads/gfg_200X200.png'); background-repeat:no-repeat; background-origin:intial; border:1px double; text-align:justify; } </style> </head> <body> <div class="gfg"> <p> Prepare for the Recruitment drive of product based companies like Microsoft, Amazon, Adobe etc with a free online placement preparation course. The course focuses on various MCQ's & Coding question likely to be asked in the interviews & make your upcoming placement season efficient and successful. </p> </div> </body> </html>
- Output:
padding-box:此屬性用於將背景圖像的原點設置為左上角的填充邊。
- 用法:
background-origin:padding-box;
- 例:
<!DOCTYPE html> <html> <head> <title>background-origin property</title> <style> .gfg { padding:40px; width:400px; background-image: url('https://media.geeksforgeeks.org/wp-content/cdn-uploads/gfg_200X200.png'); background-repeat:no-repeat; background-origin:padding-box; border:1px double; text-align:justify; } </style> </head> <body> <div class="gfg"> <p> Prepare for the Recruitment drive of product based companies like Microsoft, Amazon, Adobe etc with a free online placement preparation course. The course focuses on various MCQ's & Coding question likely to be asked in the interviews & make your upcoming placement season efficient and successful. </p> </div> </body> </html>
- 輸出:
border-box:此屬性用於將圖像設置為網頁正文的邊界,即絕對左上角。
- 用法:
background-origin:border-box;
- 例:
<!DOCTYPE html> <html> <head> <title>background-origin property</title> <style> .gfg { padding:40px; width:400px; background-image: url('https://media.geeksforgeeks.org/wp-content/cdn-uploads/gfg_200X200.png'); background-repeat:no-repeat; background-origin:border-box; border:1px double; text-align:justify; } </style> </head> <body> <div class="gfg"> <p> Prepare for the Recruitment drive of product based companies like Microsoft, Amazon, Adobe etc with a free online placement preparation course. The course focuses on various MCQ's & Coding question likely to be asked in the interviews & make your upcoming placement season efficient and successful. </p> </div> </body> </html>
- 輸出:
content-box:此屬性用於根據使用該屬性的部門/主體的內容來設置背景的原點。
- 用法:
background-origin:content-box;
- 例:
<!DOCTYPE html> <html> <head> <title>background-origin property</title> <style> .gfg { padding:40px; width:400px; background-image: url('https://media.geeksforgeeks.org/wp-content/cdn-uploads/gfg_200X200.png'); background-repeat:no-repeat; background-origin:content-box; border:1px double; text-align:justify; } </style> </head> <body> <div class="gfg"> <p> Prepare for the Recruitment drive of product based companies like Microsoft, Amazon, Adobe etc with a free online placement preparation course. The course focuses on various MCQ's & Coding question likely to be asked in the interviews & make your upcoming placement season efficient and successful. </p> </div> </body> </html>
- 輸出:
繼承:用於從已使用的代碼繼承屬性(父屬性),否則默認情況下用作padding-box。
- 用法:
background-origin:inherit;
- 例:
<!DOCTYPE html> <html> <head> <title>background-origin property</title> <style> .gfg { padding:40px; width:400px; background-image: url('https://media.geeksforgeeks.org/wp-content/cdn-uploads/gfg_200X200.png'); background-repeat:no-repeat; background-origin:inherit; border:1px double; text-align:justify; } </style> </head> <body> <div class="gfg"> <p> Prepare for the Recruitment drive of product based companies like Microsoft, Amazon, Adobe etc with a free online placement preparation course. The course focuses on various MCQ's & Coding question likely to be asked in the interviews & make your upcoming placement season efficient and successful. </p> </div> </body> </html>
- 輸出:
支持的瀏覽器:CSS | Java支持的瀏覽器。下麵列出了background-origin屬性:
- 穀歌瀏覽器
- IE瀏覽器
- Firefox
- Opera
- Safari
相關用法
- HTML Style backgroundOrigin用法及代碼示例
- CSS transition-property用法及代碼示例
- CSS nav-up用法及代碼示例
- CSS top屬性用法及代碼示例
- CSS all屬性用法及代碼示例
- CSS nav-right用法及代碼示例
- CSS right屬性用法及代碼示例
- CSS nav-down用法及代碼示例
- CSS columns屬性用法及代碼示例
- CSS zoom屬性用法及代碼示例
- CSS nav-left用法及代碼示例
- CSS resize屬性用法及代碼示例
- CSS nav-index用法及代碼示例
- CSS will-change用法及代碼示例
- CSS clip屬性用法及代碼示例
注:本文由純淨天空篩選整理自RahulRanjan4大神的英文原創作品 CSS | background-origin property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。