背景 background
(建議以電腦閱讀此篇)
background-color
設定背景顏色,範例:body {background-color: yellow;}在 css 中,顏色可以有三種表示顏色的名字 red16進制值 #ff0000RGB值 rgb(255,0,0)
設定背景圖,範例:body {background-image: url('demo.png');}
背景圖重複方式,範例:body {background-image: url('demo.png');background-repeat: repeat-x;}兩個方向都要重複: repeat橫向重複: repeat-x垂直重複: repeat-y不重複: no-repeat
background-attachment背景圖對其位置,範例:body {background-image: url('demo.png');background-repeat: no-repeat;background-position: right top;}靠上:top靠下:bottom靠左:left靠右:right置中:center
background-size設定背景圖是否固定或跟著畫面滾動,範例:body {background-image: url('demo.png');background-attachment: fixed;}固定不動:fixed跟著畫面動:scroll
設定背景圖大小,範例:#ex1 {background-image: url('demo.png');background-repeat: no-repeat;background-size: auto;}#ex2 {background-image: url('demo.png');background-repeat: no-repeat;background-size: 100px 200px;}自動:auto符合容器大小:cover
如有錯誤,歡迎在下方留言討論喔 ~