溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

css3中復(fù)合屬性是什么意思

發(fā)布時間:2021-12-14 17:34:23 來源:億速云 閱讀:241 作者:小新 欄目:web開發(fā)

這篇文章將為大家詳細(xì)講解有關(guān)css3中復(fù)合屬性是什么意思,小編覺得挺實(shí)用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

在css3中,復(fù)合屬性又稱“簡寫屬性”,指的是可以在一個聲明中同時書寫多個屬性代碼、控制多種樣式的屬性;例如border屬性,就可以在一個聲明中控制邊框?qū)挾?、邊框樣式和邊框顏色?/p>

本教程操作環(huán)境:windows7系統(tǒng)、CSS3&&HTML5版、Dell G3電腦。

在css3中,復(fù)合屬性又稱“簡寫屬性”,指的是可以在一個聲明中同時設(shè)置多個屬性、控制多種樣式的屬性。

我們知道border屬性可以同時規(guī)定邊框的粗細(xì)、顏色和邊框類型。例如:

border:2px solid blue;

所謂復(fù)合屬性就是類似于border這樣的屬性,能夠一個屬性規(guī)定對象的多種樣式。比較常用的復(fù)合屬性有font、border、margin、padding和background等。當(dāng)然這些屬性也是可以拆分的,例如border屬性就可以拆分為:border-color、border-width和border-style。

CSS 常用復(fù)合屬性

background

// background: background-color background-image
background-repeat background-attachment background-position/background-size
// background: 背景色 圖片地址 是否重復(fù) 是否固定 定位/圖片尺寸

background: #fff url(https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2657596156,4172056089&fm=26&gp=0.jpg) no-repeat fixed 0 0/100%

注意background-attachmentbackground-size會互相影響


animation

// animation: name duration timing-function delay iteration-count direction fill-mode play-state;
// animation: 動畫名稱 動畫時長 動畫函數(shù) 延遲時間 動畫次數(shù) 動畫方向 動畫狀態(tài) 動畫運(yùn)行或者暫停
animation: move 5s linear 0s infinite alternate both running;

注意animation屬性里有一些是可以直接省略的,比如animation-direction animation-fill-mode animation-play-state,每個屬性效果都會有默認(rèn)值,詳細(xì)可參考文檔


border

// border: width style color;
// border: 寬度 邊框類型 邊框顏色
border: 2px dashed #000;

outline

// outline: width style color;
// outline: 寬度 邊框類型 邊框顏色
outline: 2px dashed #000;

outline不占空間,上述示例可看出outline會層疊在一起


border-image

//  border-image: source slice width outset repeat;
// border-image: 圖片路徑 偏移 邊框?qū)挾?nbsp;圖像區(qū)域超出的量 邊框圖片重復(fù)類型
border-image: url(https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1576497337284&di=26ef95dbb3b7e1a4766732e6f95f1e8d&imgtype=0&src=http%3A%2F%2Fbpic.588ku.com%2Felement_origin_min_pic%2F00%2F39%2F06%2F4556d5b0a022b0a.jpg) 100 100 100 100 round;

著重注意background-image-slice屬性,正確切割才能得到理想顯示


box-shadow

// box-shadow: h-shadow v-shadow blur spread color inset;
// box-shadow: 水平陰影 垂直陰影 模糊距離 陰影尺寸 陰影顏色 陰影類型
box-shadow: 2px dashed #000;

font

// font: style variant weight size/line-height family;
// font: 字體樣式 字體異體 字體粗細(xì) 字體字號/行高 字體系列
font: italic small-caps bold 24px/50px Serif;

list-style

// list-style: type position image;
// list-style: 標(biāo)記類型 標(biāo)記位置 標(biāo)記圖像;
list-style:lower-roman inside;
list-style: inside url(https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=167525435,1152422064&fm=26&gp=0.jpg);

設(shè)置圖片之后,類型屬性將失效


transition

// transition: property duration timing-function delay;
// transition: 過渡屬性 過渡時長 過渡效果 過渡延時;
transition: width 1s linear 0s;

設(shè)置圖片之后,類型屬性將失效


padding

// padding: 上 右 下 左;
// padding: 上 左右 下;
// padding: 上下 左右;
// padding: 上下左右;
padding: 10px 11px 12px 13px;
padding: 10px 20px 13px;
padding: 10px 20px;
padding: 10px;

margin

// margin: 上 右 下 左;
// margin: 上 左右 下;
// margin: 上下 左右;
// margin: 上下左右;
margin: 10px 11px 12px 13px;
margin: 10px 20px 13px;
margin: 10px 20px;
margin: 10px;

關(guān)于“css3中復(fù)合屬性是什么意思”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI