background

  • 版本网址缩略名: CSS/background
  • 版本标题: background
  • 版本 id: 89580
  • 创建于:
  • 创建者: Mickeyboy
  • 是否是当前版本?
  • 评论 New page: <breadcrumbs></breadcrumbs> {{CSSRef}} == 摘要 == <code>background</code> 属性是一个速记属性用来将单个设置的背景属性写在一行。<code>background</code> 可以设...

修订内容

{{template.CSSRef()}}

摘要

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

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

语法

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.

例子

{{template.CSSRefExampleLink("background")}}

body { 
    background: red;
}

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

提示

Given a valid declaration, the background property first sets the individual background properties to their initial values, then assigns the explicit values specified in the declaration. You do not have to define a value for each of the individual properties, only those you want to change from their initial defaults.

规范

浏览器兼容性

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

参阅

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


Categorias

Interwiki Language Links


{{ wiki.languages( { "en": "en/CSS/background", "it": "it/CSS/background", "pl": "pl/CSS/background" } ) }}

修订版来源

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

.topbanner {
    background: url("topbanner.png") #00D repeat fixed;
}
</pre>
<h3 name=".E6.8F.90.E7.A4.BA"> 提示 </h3>
<p>Given a valid declaration, the <code>background</code> property first sets the individual background properties to their initial values, then assigns the explicit values specified in the declaration.  You do not have to define a value for each of the individual properties, only those you want to change from their initial defaults.
</p>
<h3 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 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 name=".E5.8F.82.E9.98.85"> 参阅 </h3>
<p>{{template.Cssxref("background")}}, 
{{template.Cssxref("background-attachment")}}, 
{{template.Cssxref("background-color")}}, 
{{template.Cssxref("background-image")}}, 
{{template.Cssxref("background-position")}}, 
{{template.Cssxref("background-repeat")}}
</p><p><br>
<span class="comment">Categorias</span>
</p><p><span class="comment">Interwiki Language Links</span>
</p><p><br>
</p>
<div class="noinclude">
</div>
{{ wiki.languages( { "en": "en/CSS/background", "it": "it/CSS/background", "pl": "pl/CSS/background" } ) }}
恢复到这个版本