大數據

CSS樣式更改篇——背景Background

上篇文章主要講述了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/

Leave a Reply

Your email address will not be published. Required fields are marked *