中文字幕一区二区人妻电影,亚洲av无码一区二区乱子伦as ,亚洲精品无码永久在线观看,亚洲成aⅴ人片久青草影院按摩,亚洲黑人巨大videos

Style background 屬性

Style 對(duì)象參考手冊(cè) Style 對(duì)象

定義和用法

background 屬性以速記形式設(shè)置或返回最多五個(gè)獨(dú)立的背景屬性。

通過(guò)該屬性,您可以設(shè)置/返回:

  • background-color
  • background-image
  • background-repeat
  • background-attachment
  • background-position

上述的屬性,也可以設(shè)置單獨(dú)的樣式屬性。強(qiáng)烈建議使用單獨(dú)的屬性這樣有更好的可控性。

語(yǔ)法

設(shè)置 background 屬性:

Object.style.background="color image repeat attachment position"

返回 background 屬性:

Object.style.background

提示:background 屬性的默認(rèn)值是:transparent none repeat scroll 0% 0%。

參數(shù) 描述
color 設(shè)置一個(gè)元素的背景顏色
image 設(shè)置一個(gè)元素的背景圖像
repeat 設(shè)置如何重復(fù)背景圖像
attachment 設(shè)置背景圖像是否固定或者隨著頁(yè)面的其余部分滾動(dòng)
position 設(shè)置背景圖像的起始位置

瀏覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要瀏覽器都支持 background 屬性。


實(shí)例

實(shí)例

設(shè)置文檔背景的樣式:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>小白教程(json.cn)</title>
<script>
function displayResult(){
????document.body.style.background="#f3f3f3 url('img_tree.png') no-repeat right top";
}
</script>
</head>
<body>

<h1>Hello World!</h1>
<br>
<button type="button" onclick="displayResult()">設(shè)置背景</button>

</body>
</html>

運(yùn)行代碼 ?

Style 對(duì)象參考手冊(cè) Style 對(duì)象其他擴(kuò)展