版本 89585 / background

  • 版本网址缩略名: CSS/background
  • 版本标题: background
  • 版本 id: 89585
  • 创建于:
  • 创建者: Yuichiro
  • 是否是当前版本?
  • 评论 20 words added
标签: 

修订内容

{{ CSSRef() }}

摘要

background 属性是一个速记属性用来将单个设置的背景属性写在一行。background 可以设置: {{ Cssxref("background-attachment") }}, {{ Cssxref("background-color") }}, {{ Cssxref("background-image") }}, {{ Cssxref("background-position") }}, {{ Cssxref("background-repeat") }}.

  • 初始值: 参阅单个属性。
  • 应用于:所有元素。
  • 继承性: 无
  • 百分数:{{ Cssxref("background-position") }}
  • 媒体: visual
  • 计算值:参阅单个属性。

语法

background: [background-color || background-image ||
    background-repeat || background-attachment ||
    background-position] | inherit]

background-color
参看 background-color.
background-image 
参看 background-image.
background-repeat 
参看 background-repeat.
background-attachment 
参看 background-attachment.
background-position 
参看 background-position.

例子

{{ CSSRefExampleLink("background") }}

body { 
    background: red;
}

.topbanner {
    background: url("topbanner.png") #00D repeat fixed;
}

提示

存在有效声明的情况下,background属性首先将背景设置为初始值,然后设定为声明中指定的值。你不必为每一个属性单独定义,你只对需要更改默认值的属性进行设置。

规范

浏览器兼容性

Browser Lowest Version
Internet Explorer 4
Firefox 1
Netscape 6
Opera 3.5

参阅

{{ Cssxref("background") }}, {{ Cssxref("background-attachment") }}, {{ Cssxref("background-color") }}, {{ Cssxref("background-image") }}, {{ Cssxref("background-position") }}, {{ Cssxref("background-repeat") }}


Categorias

Interwiki Language Links

 

 

 

{{ languages( { "de": "de/CSS/background", "en": "en/CSS/background", "es": "es/CSS/background", "fr": "fr/CSS/background", "it": "it/CSS/background", "ja": "ja/CSS/background", "ko": "ko/CSS/background", "pl": "pl/CSS/background" } ) }}

修订版来源

<p>{{ CSSRef() }}</p>
<h3 id=".E6.91.98.E8.A6.81" name=".E6.91.98.E8.A6.81">摘要</h3>
<p><code>background</code> 属性是一个速记属性用来将单个设置的背景属性写在一行。<code>background</code> 可以设置: {{ Cssxref("background-attachment") }}, {{ Cssxref("background-color") }}, {{ Cssxref("background-image") }}, {{ Cssxref("background-position") }}, {{ Cssxref("background-repeat") }}.</p>
<ul> <li>初始值: 参阅单个属性。</li> <li>应用于:所有元素。</li> <li>继承性: 无</li> <li>百分数:{{ Cssxref("background-position") }}</li> <li>媒体: <a href="/cn/CSS/Media/Visual" title="cn/CSS/Media/Visual">visual</a></li> <li>计算值:参阅单个属性。</li>
</ul>
<h3 id=".E8.AF.AD.E6.B3.95" name=".E8.AF.AD.E6.B3.95">语法</h3>
<pre class="eval">background: [<em>background-color</em> || <em>background-image</em> ||
    <em>background-repeat</em> || <em>background-attachment</em> ||
    <em>background-position</em>] | <em>inherit</em>]
</pre>
<h3 id=".E5.80.BC" name=".E5.80.BC">值</h3>
<dl> <dt>background-color</dt> <dd>参看 <code><a href="/cn/CSS/background-color" title="cn/CSS/background-color">background-color</a></code>.</dd> <dt>background-image </dt> <dd>参看 <code><a href="/cn/CSS/background-image" title="cn/CSS/background-image">background-image</a></code>.</dd> <dt>background-repeat </dt> <dd>参看 <code><a href="/cn/CSS/background-repeat" title="cn/CSS/background-repeat">background-repeat</a></code>.</dd> <dt>background-attachment </dt> <dd>参看 <code><a href="/cn/CSS/background-attachment" title="cn/CSS/background-attachment">background-attachment</a></code>.</dd> <dt>background-position </dt> <dd>参看 <code><a href="/cn/CSS/background-position" title="cn/CSS/background-position">background-position</a></code>.</dd>
</dl>
<h3 id=".E4.BE.8B.E5.AD.90" name=".E4.BE.8B.E5.AD.90">例子</h3>
<p>{{ CSSRefExampleLink("background") }}</p>
<pre>body { 
    background: red;
}

.topbanner {
    background: url("topbanner.png") #00D repeat fixed;
}
</pre>
<h3 id=".E6.8F.90.E7.A4.BA" name=".E6.8F.90.E7.A4.BA">提示</h3>
<p>存在有效声明的情况下,<code>background</code>属性首先将背景设置为初始值,然后设定为声明中指定的值。你不必为每一个属性单独定义,你只对需要更改默认值的属性进行设置。</p>
<h3 id=".E8.A7.84.E8.8C.83" name=".E8.A7.84.E8.8C.83">规范</h3>
<ul> <li><a class="external" href="http://www.w3.org/TR/CSS1#background">CSS 1</a></li> <li><a class="external" href="http://www.w3.org/TR/CSS21/colors.html#propdef-background">CSS 2.1</a></li> <li><a class="external" href="http://www.w3.org/TR/2005/WD-css3-background-20050216/#the-background">CSS 3</a></li>
</ul>
<h3 id=".E6.B5.8F.E8.A7.88.E5.99.A8.E5.85.BC.E5.AE.B9.E6.80.A7" name=".E6.B5.8F.E8.A7.88.E5.99.A8.E5.85.BC.E5.AE.B9.E6.80.A7">浏览器兼容性</h3>
<table class="standard-table"> <tbody> <tr> <th>Browser</th> <th>Lowest Version</th> </tr> <tr> <td>Internet Explorer</td> <td>4</td> </tr> <tr> <td>Firefox</td> <td>1</td> </tr> <tr> <td>Netscape</td> <td>6</td> </tr> <tr> <td>Opera</td> <td>3.5</td> </tr> </tbody>
</table>
<h3 id=".E5.8F.82.E9.98.85" name=".E5.8F.82.E9.98.85">参阅</h3>
<p>{{ Cssxref("background") }}, {{ Cssxref("background-attachment") }}, {{ Cssxref("background-color") }}, {{ Cssxref("background-image") }}, {{ Cssxref("background-position") }}, {{ Cssxref("background-repeat") }}</p>
<p><br>
<span class="comment">Categorias</span></p>
<p><span class="comment">Interwiki Language Links</span></p>
<p> </p>
<p> </p>
<p> </p>

<p>{{ languages( { "de": "de/CSS/background", "en": "en/CSS/background", "es": "es/CSS/background", "fr": "fr/CSS/background", "it": "it/CSS/background", "ja": "ja/CSS/background", "ko": "ko/CSS/background", "pl": "pl/CSS/background" } ) }}</p>
恢复到这个版本