這篇文章給大家分享的是有關css中與背景相關的屬性有哪些的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
創新互聯專注于沐川企業網站建設,響應式網站設計,商城網站制作。沐川網站建設公司,為沐川等地區提供建站服務。全流程按需定制開發,專業設計,全程項目跟蹤,創新互聯專業和態度為您提供的服務
1、css背景屬性之為內容設置背景色:background-color;
屬性:
顏色;
inherit;繼承父級樣式
box.html
<!doctypehtml>
<html>
<head>
<matecharset="utf-8">
<title>背景</title>
<linkhref="box.css"type="text/css"rel="stylesheet">
</head>
<body>
<p為內容設置背景色:background-color;</p>
</body>
</html>
box.css
body{
background-color:#123456;
}
2、css背景屬性之為內容設置背景為圖片background-image:url();
box.css
body{
background-color:#123456;
background-image:url(image.png);
}
3、css背景屬性之固定背景圖片background-attachment
(在CSS中使用background-attachment屬性可以將圖片固定在瀏覽器上,如果拖動滾動條,背景圖片不會隨著網頁內容的滾動而滾動,像文字浮在圖片上)
屬性值:
scroll;背景圖片隨內容滾動,默認值
fixed;背景圖片固定,不隨內容滾動
inherit;繼承父類樣式
box.css
body{
background-color:#123456;
background-image:url(image.png);
background-attachment:fixed;
font-size:45px;
}
4、css背景屬性之背景圖片平鋪background-repeat;
屬性值:
repeat;平鋪背景圖片;默認
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;
}
感謝各位的閱讀!關于“css中與背景相關的屬性有哪些”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
分享題目:css中與背景相關的屬性有哪些
網站地址:http://m.2m8n56k.cn/article16/jdsggg.html
成都網站建設公司_創新互聯,為您提供網站內鏈、企業建站、網站設計公司、小程序開發、標簽優化、虛擬主機
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯