十年網站開發(fā)經驗 + 多家企業(yè)客戶 + 靠譜的建站團隊
量身定制 + 運營維護+專業(yè)推廣+無憂售后,網站問題一站解決
小編給大家分享一下CSS設置背景屬性的方法,希望大家閱讀完這篇文章后大所收獲,下面讓我們一起去探討吧!
開福ssl適用于網站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!
背景相關屬性主要有:
background-color 背景顏色
background-image 背景圖片
background-repeat 是否平鋪 repeat (默認平鋪) | repeat-x(水平平鋪) | repeat-y (垂直平鋪)| no-repeat (不平鋪)
background-position 背景位置 length(百分數(shù))|position(top center button left right) 一般兩個一起用,如果至指定一個方向另一個方向默認為center,兩種方法也可以混搭。方位名詞沒有順序區(qū)分,而使用百分數(shù)時時有順序的,先是水平后是垂直
background-attachment 背景固定還是滾動 scroll | fixed
background:背景顏色 背景圖片 是否平鋪 背景固定還是滾動 背景位置
#p1 { width: 300px; height: 300px; background-color: blue; /*默認是transparent透明的*/ /* background-color: transparent; */ background-image: url(Images/2.jpg); background-repeat: no-repeat; /*不平鋪,默認是水平垂直平鋪*/ /* background-repeat: repeat-y; */ /* background-repeat: repeat-x; */ /* background-position: right bottom; */ background-position: 10% center; background-attachment: fixed; }
想要背景半透明 在指定顏色時使用 rgba( r, g b ,a) ,a就是指明透明度
p { width: 100%; height: 300px; background-color: rgba(0, 0, 0, 0.6); }
當要使用多張背景圖片時使用background來指定多個url,每組之間用‘,’逗號隔開,若圖片有重疊,則前一張覆蓋后一張圖片,但是整體背景顏色必須在最后一個url后指定。
p { width: 100%; height: 300px; background: url(Images/2.jpg) no-repeat left top, url(Images/3.jpg) no-repeat right bottom blue; }
看完了這篇文章,相信你對CSS設置背景屬性的方法有了一定的了解,想了解更多相關知識,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!