上篇文章主要講述了CSS的基礎用法,講述了如何定義頭檔案,導入CSS檔案,id和class選擇器,元素選擇器,後代選擇器,子元素選擇器,兄弟選擇器,僞類選擇器等等,讓大家對CSS選擇器有個簡單的認識和了解。這篇接上篇文章,繼續講解CSS的基礎用法。
背景Background
背景可以設定很多,比如背景顔色,背景圖檔,背景定位,背景重複,背景關聯,
1)).背景顔色
<div style='background-color='red'></div>
2)).背景圖檔
<div style='background-image: url('1.png');'></div>
3)).背景定位
<div style='background-position:center'></div>
center 中間
top 頂部
bottom 底部
right 右邊
left 左邊
還可以使用百分比來設定定位:
<div style='background-position:40% 50%'></div>
或者設定像素值:
<div style='background-position:100px 100px'></div>
4)).背景顯示方式
<div style=' background-repeat:repeat-x'></div>
repeat-x 水準平鋪圖檔
repeat-y 垂直平鋪圖檔
no-repeat 不平鋪圖檔
5)).背景滾動條
<div style='background-attachment:fixed'></div>
fixed 固定 不出現滾動條
scroll 出現滾動條
no 沒有滾動條
6)).背景大小
<div style='background-size:50px 50px'></div>
7)).背景圖檔的定位區域
<div style='background-origin:content-box'></div>
content-box 文本内容區域
padding-box 内邊距區域
border-box 外邊框區域
8)).背景裁剪區域
<div style='background-clip:content-box'></div>
content-box 裁剪文本内容區域
padding-box 裁剪内邊距區域
border-box 裁剪外邊框區域
總結
這篇文章主要介紹了CSS樣式更改篇中的背景Background的基本設定,希望讓大家對CSS選擇器有個簡單的認識和了解。
看完本文有收獲?請轉發分享給更多的人
IT共享之家
入群請在微信背景回複【入群】
想要學習更多,請前往Python爬蟲與資料挖掘專用網站:
http://pdcfighting.com/