科技知識動態:background-image屬性怎么用

導讀跟大家講解下有關background-image屬性怎么用,相信小伙伴們對這個話題應該也很關注吧,現在就為小伙伴們說說background-image屬性怎么用,

跟大家講解下有關background-image屬性怎么用,相信小伙伴們對這個話題應該也很關注吧,現在就為小伙伴們說說background-image屬性怎么用,小編也收集到了有關background-image屬性怎么用的相關資料,希望大家看到了會喜歡。

background-image屬性是用來設置元素的一個或多個背景圖像,用逗號(,)分隔。

CSS background-image屬性

作用:background-image屬性為元素設置背景圖像。

語法:

background-image:url(圖片路徑)

說明:background-image屬性設置的背景圖像會占據了元素的全部尺寸,包括內邊距和邊框,但不包括外邊距。默認地,背景圖像位于元素的左上角,并在水平和垂直方向上重復。

提示:請設置一種可用的背景顏色,這樣的話,假如背景圖像不可用,可以使用背景色帶代替。

CSS background-image屬性的使用示例

<!DOCTYPE html><html><head><meta charset="utf-8"> <style>#example1 { background-color:#cccccc; background-image:url("https://img.php.cn/upload/article/000/000/024/5c6a290265dba776.gif"),url("https://img.php.cn/upload/article/000/000/024/5c6a2793a13ac244.gif"); background-position: right bottom, left top; background-repeat: no-repeat, repeat; padding: 15px;}</style></head><body><div id="example1"><h1>Hello World!</h1><p>測試文本!測試文本!測試文本!測試文本!測試文本!測試文本!測試文本!</p><p>測試文本!測試文本!測試文本!測試文本!測試文本!測試文本!測試文本!測試文本!測試文本!測試文本!</p></div></body></html>

效果圖:

1.jpg

以上就是本篇文章的全部內容,希望能對大家的學習有所幫助。

以上就是background-image屬性怎么用的詳細內容,更多請關注php中文網其它相關文章!

來源:php中文網

免責聲明:本文由用戶上傳,如有侵權請聯系刪除!