標籤:屬性 type tle attach 複合 傳參 寬高 預設 img
<!DOCTYPE html><html> <head> <meta charset="utf-8"> <title>背景</title> <style> div{ width: 300px; height: 300px; border: 10px solid red; background-image:url(https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1493309945592&di=b3051d0bce128fd8b75d9c0b9c2ee033&imgtype=0&src=http%3A%2F%2Fpic67.nipic.com%2Ffile%2F20150514%2F21036787_181947848862_2.jpg) ; background-size: cover; } /*img{ width: 100%; height: 100%; }*/ </style> </head> <body> <!-- 若容器沒設定寬高 容器中的內容可以把容器撐起來 但背景不會佔用容器的寬高 --> <div> <!--<img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1493309945592&di=b3051d0bce128fd8b75d9c0b9c2ee033&imgtype=0&src=http%3A%2F%2Fpic67.nipic.com%2Ffile%2F20150514%2F21036787_181947848862_2.jpg" />--> </div> </body></html> <!-- background 背景 background-color 背景色 background-image 背景圖片 background-repeat 背景圖片是否重複 background-position 背景位置 background-attachment 背景圖片是否滾動 --> <!-- background-position:; 傳兩個參數 分別代表X和Y 可以直接傳參數例如 background-position:10px 10px; 也可以傳關鍵字 X關鍵字有:Center,left,right//分別代表中間,左邊,右邊 Y關鍵字有:top,center,bottom//分別代表上邊,中間,下邊 若不傳參數,則預設0px 0px或者left top --> <!-- background-attachment:; scoll 背景滾動(預設屬性) fixed 背景固定 --> <!-- 背景還可以按照複合屬性寫法來寫 -->
html頁面背景設定相關