溫馨提示×

溫馨提示×

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

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

css中與背景相關的屬性有哪些

發(fā)布時間:2022-03-01 15:19:41 來源:億速云 閱讀:151 作者:小新 欄目:web開發(fā)

這篇文章給大家分享的是有關css中與背景相關的屬性有哪些的內(nèi)容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。

  1、css背景屬性之為內(nèi)容設置背景色:background-color;

  屬性:

  顏色;

  inherit;繼承父級樣式

  box.html

  <!doctypehtml>

  <html>

  <head>

  <matecharset="utf-8">

  <title>背景</title>

  <linkhref="box.css"type="text/css"rel="stylesheet">

  </head>

  <body>

  <p為內(nèi)容設置背景色:background-color;</p>

  </body>

  </html>

  box.css

  body{

  background-color:#123456;

  }

  2、css背景屬性之為內(nèi)容設置背景為圖片background-image:url();

  box.css

  body{

  background-color:#123456;

  background-image:url(image.png);

  }

  3、css背景屬性之固定背景圖片background-attachment

 ?。ㄔ贑SS中使用background-attachment屬性可以將圖片固定在瀏覽器上,如果拖動滾動條,背景圖片不會隨著網(wǎng)頁內(nèi)容的滾動而滾動,像文字浮在圖片上)

  屬性值:

  scroll;背景圖片隨內(nèi)容滾動,默認值

  fixed;背景圖片固定,不隨內(nèi)容滾動

  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中與背景相關的屬性有哪些”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

向AI問一下細節(jié)

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

css
AI