這篇文章給大家分享的是有關(guān)css中與背景相關(guān)的屬性有哪些的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。
創(chuàng)新互聯(lián)專注于沐川企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站設(shè)計(jì),商城網(wǎng)站制作。沐川網(wǎng)站建設(shè)公司,為沐川等地區(qū)提供建站服務(wù)。全流程按需定制開發(fā),專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)
1、css背景屬性之為內(nèi)容設(shè)置背景色:background-color;
屬性:
顏色;
inherit;繼承父級(jí)樣式
box.html
<!doctypehtml>
<html>
<head>
<matecharset="utf-8">
<title>背景</title>
<linkhref="box.css"type="text/css"rel="stylesheet">
</head>
<body>
<p為內(nèi)容設(shè)置背景色:background-color;</p>
</body>
</html>
box.css
body{
background-color:#123456;
}
2、css背景屬性之為內(nèi)容設(shè)置背景為圖片background-image:url();
box.css
body{
background-color:#123456;
background-image:url(image.png);
}
3、css背景屬性之固定背景圖片background-attachment
(在CSS中使用background-attachment屬性可以將圖片固定在瀏覽器上,如果拖動(dòng)滾動(dòng)條,背景圖片不會(huì)隨著網(wǎng)頁內(nèi)容的滾動(dòng)而滾動(dòng),像文字浮在圖片上)
屬性值:
scroll;背景圖片隨內(nèi)容滾動(dòng),默認(rèn)值
fixed;背景圖片固定,不隨內(nèi)容滾動(dòng)
inherit;繼承父類樣式
box.css
body{
background-color:#123456;
background-image:url(image.png);
background-attachment:fixed;
font-size:45px;
}
4、css背景屬性之背景圖片平鋪background-repeat;
屬性值:
repeat;平鋪背景圖片;默認(rèn)
no-repeat;不平鋪圖片;
repeat-x;在水平方向平鋪
repert-y;在豎直方向平鋪
box.css
body{
background-color:#123456;
background-image:url(image.png);
background-attachment:fixed;
font-size:45px;
background-repeat:repeat-y;
}
5、css背景屬性之背景圖片定位background-position
屬性值:
top;頂部
center;中間
bottom;底部
right;右邊
left;左邊
inherit;繼承父類樣式
樣式:
xxxpx,xxxpx;
xxx%,xxx%;
xxxpx,top;
box.css
body{
background-color:#123456;
background-image:url(image.png);
background-attachment:fixed;
font-size:45px;
background-repeat:no-repeat;
background-position:left;
}
感謝各位的閱讀!關(guān)于“css中與背景相關(guān)的屬性有哪些”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
分享題目:css中與背景相關(guān)的屬性有哪些
網(wǎng)站地址:http://bm7419.com/article16/jdsggg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內(nèi)鏈、企業(yè)建站、網(wǎng)站設(shè)計(jì)公司、小程序開發(fā)、標(biāo)簽優(yōu)化、虛擬主機(jī)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)