Mafaa ya CodeW3C kwenye Mtaani wa Inaripia
  • Mafaa ya HTML ya Sera
  • 浏览器脚本
  • 服务器脚本
  • 编程教程
  • XML 系列教程
  • 建站手册
  • 参考手册

课程表

JS 参考手册

  • JS 参考手册(类别排序)
  • JS 参考手册(字母排序)

JavaScript

  • JS Array
  • JS Boolean
  • JS Class
  • JS Date
  • JS Error
  • JS Global
  • JS JSON
  • JS Map
  • JS Math
  • JS Number
  • JS Promise
  • JS RegExp
  • JS Set
  • JS String
  • JS 对象
  • JS 运算符
  • JS 运算符优先级
  • JS 语句
  • JS 类型化数组

Window

  • Window 对象
  • Window Console
  • Window History
  • Window Location
  • Window Navigator
  • Window Screen

HTML DOM

  • HTML Document
  • HTML Element
  • HTML Attribute
  • HTML Event
  • HTML Event 对象
  • HTML Collection
  • HTML NodeList
  • HTML DOMTokenList
  • HTML Style

Web API

  • API Canvas
  • API Console
  • API Fetch
  • API Fullscreen
  • API Geolocation
  • API History
  • API MediaQueryList
  • API Storage
  • API Validation
  • API Web

HTML 对象

  • <a>
  • <abbr>
  • <address>
  • <area>
  • <article>
  • <aside>
  • <audio>
  • <b>
  • <base>
  • <bdo>
  • <blockquote>
  • <body>
  • <br>
  • <button>
  • <canvas>
  • <caption>
  • <cite>
  • <code>
  • <col>
  • <colgroup>
  • <datalist>
  • <dd>
  • <del>
  • <details>
  • <dfn>
  • <dialog>
  • <div>
  • <dl>
  • <dt>
  • <em>
  • <embed>
  • <fieldset>
  • <figcaption>
  • <figure>
  • <footer>
  • <form>
  • <head>
  • <header>
  • <h1> - <h6>
  • <hr>
  • <html>
  • <i>
  • <iframe>
  • <img>
  • <ins>
  • <input> button
  • <input> checkbox
  • <input> color
  • <input> date
  • <input> datetime
  • <input> datetime-local
  • <input> email
  • <input> file
  • <input> hidden
  • <input> image
  • <input> month
  • <input> number
  • <input> password
  • <input> radio
  • <input> range
  • <input> reset
  • <input> search
  • <input> submit
  • <input> text
  • <input> time
  • <input> url
  • <input> week
  • <kbd>
  • <label>
  • <legend>
  • <li>
  • <link>
  • <map>
  • <mark>
  • <menu>
  • <menuitem>
  • <meta>
  • <meter>
  • <nav>
  • <object>
  • <ol>
  • <optgroup>
  • <option>
  • <output>
  • <p>
  • <param>
  • <pre>
  • <progress>
  • <q>
  • <s>
  • <samp>
  • <script>
  • <section>
  • <select>
  • <small>
  • <source>
  • <span>
  • <strong>
  • <sub>
  • <summary>
  • <sup>
  • <table>
  • <tbody>
  • <td>
  • <tfoot>
  • <th>
  • <thead>
  • <tr>
  • <textarea>
  • </a></li> <li><a href="/sw/jsref/dom_obj_track.html" title="HTML DOM Track mwingine"><track></a></li> <li><a href="/sw/jsref/dom_obj_u.html" title="HTML DOM Underline mwingine"><u></a></li> <li><a href="/sw/jsref/dom_obj_ul.html" title="HTML DOM Ul mwingine"><ul></a></li> <li><a href="/sw/jsref/dom_obj_var.html" title="HTML DOM Variable mwingine"><var></a></li> <li><a href="/sw/jsref/dom_obj_video.html" title="HTML DOM Video mwingine"><video></a></li> </ul> <h2>其他参考手册</h2> <ul> <li><a href="/sw/jsref/obj_cssstyledeclaration.html" title="CSSStyleDeclaration mwingine">CSSStyleDeclaration</a></li> <li><a href="/sw/jsref/jsref_type_conversion.html" title="JavaScript ujenzi kwa uagawanyika">JS 类型转换</a></li> </ul> </div> <div><h3><center> 选修课 </center><h3> <h2>课程推荐:</h2> <ul> <li><a href="/sw/howto/index.html" title="Kituu cha Vichuoro cha CodeW3C.com">Kituu cha Vichuoro cha CodeW3C.com</a></li> </ul> </div> </div> <div id="maincontent"> <div class="idea"> <a href="/"><button>English</button></a> <a href="/zh/"><button>中文</button></a> <a href="/oldzh/"><button>繁體中文</button></a> <a href="/ru/"><button>Русский</button></a> <a href="/fr/"><button>Français</button></a> <a href="/de/"><button>Deutsch</button></a> <a href="/es/"><button>Español</button></a> <a href="/pt/"><button>Português</button></a> <a href="/ja/"><button>日本語</button></a> <a href="/ko/"><button>한국어</button></a> <a href="/it/"><button>Italiano</button></a> <a href="/ar/"><button>عربي</button></a> <a href="/hi/"><button>हिंदी</button></a> <a href="/bn/"><button>বাংলা</button></a> <a href="/ms/"><button>Bahasa Malaysia</button></a> <a href="/my/"><button>မြန်မာ</button></a> <a href="/vi/"><button>Tiếng Việt</button></a> <a href="/th/"><button>ภาษาไทย</button></a> <a href="/lo/"><button>ລາວ</button></a> <a href="/id/"><button>Bahasa Indonesia</button></a> <a href="/ur/"><button>اردو</button></a> <a href="/ha/"><button>Hausa</button></a> <a href="/pl/"><button>Język polski</button></a> <a href="/pa/"><button>ਪੰਜਾਬੀ</button></a> <a href="/sv/"><button>Svenska</button></a> <a href="/da/"><button>Dansk</button></a> <a href="/nl/"><button>Nederlands</button></a> <a href="/tr/"><button>Türkçe</button></a> <a href="/fi/"><button>suom.</button></a> <a href="/el/"><button>Ελληνικά</button></a> <a href="/fa/"><button>فارسی</button></a> <a href="/sw/"><button>Kiswahili</button></a> <a href="/te/"><button>తెలుగు</button></a> <a href="/tl/"><button>wikang Galu</button></a> </div> <h1>Style backgroundColor 属性</h1> <div class="prenextnav-ref"> <ul> <li> 上一页 <a href="/sw/jsref/prop_style_backgroundattachment.html" title="Umoja wa msingi wa backgroundAttachment wa Style">backgroundAttachment</a></li> <li> 下一页 <a href="/sw/jsref/prop_style_backgroundimage.html" title="Umoja wa msingi wa backgroundImage wa Style">backgroundImage</a></li> <li> 返回上一层 <a href="/sw/jsref/dom_obj_style.html" title="HTML DOM Style 对象">HTML DOM Style 对象</a></li> </ul> </div> <div> <h2>定义和用法</h2> <p><code>backgroundColor</code> 属性设置或返回元素的背景颜色。</p> <h3>另请参阅:</h3> <p>HTML 样式:<a href="/sw/jsref/prop_style_background.html" title="Umoja wa msingi wa background wa Style">background 属性</a></p> <p>CSS 教程:<a href="/sw/css/css_background.html" title="Mabaki ya CSS">Mabaki ya CSS</a></p> <p>CSS 参考手册:<a href="/sw/cssref/pr_background-color.html" title="Umoja wa msingi wa background-color wa CSS">background-color 属性</a></p> </div> <div> <h2>实例</h2> <h3>例子 1</h3> <p>为文档设置背景颜色:</p> <pre class="language-js"> document.body.style.backgroundColor = "red"; </pre> <p class="tiy"><a target="_blank" href="/sw/tiy/t.html?f=jsck_style_backgroundcolor_1">亲自试一试</a></p> <h3>例子 2</h3> <p>设置具体 <div> 元素的背景颜色:</p> <pre class="language-js"> document.getElementById("myDiv").style.backgroundColor = "lightblue"; </pre> <p class="tiy"><a target="_blank" href="/sw/tiy/t.html?f=jsck_style_backgroundcolor_2">亲自试一试</a></p> <h3>例子 3</h3> <p>返回具体 <div> 元素的背景颜色:</p> <pre class="language-js"> alert(document.getElementById("myDiv").style.backgroundColor); </pre> <p class="tiy"><a target="_blank" href="/sw/tiy/t.html?f=jsck_style_backgroundcolor_3">亲自试一试</a></p> <h3>例子 4</h3> <p>返回文档的背景颜色:</p> <pre class="language-js"> alert(document.body.style.backgroundColor); </pre> <p class="tiy"><a target="_blank" href="/sw/tiy/t.html?f=jsck_style_backgroundcolor_4">亲自试一试</a></p> </div> <div> <h2>语法</h2> <p>返回 backgroundColor 属性:</p> <pre><i>object</i>.style.backgroundColor</pre> <p>设置 backgroundColor 属性:</p> <pre><i>object</i>.style.backgroundColor = "<i>color</i>|transparent|initial|inherit"</pre> <h3>属性值</h3> <table class="dataintable"> <tr> <th style="width: 25%;">值</th> <th>描述</th> </tr> <tr> <td><i>color</i></td> <td> <p>规定背景颜色。</p> <p>请查看 <a href="/sw/cssref/css_colors_legal.html" title="Wadogo wa rangi waadilifu wa CSS">CSS 颜色值</a>,以获取可能的颜色值的完整列表。</p> </td> </tr> <tr> <td>transparent</td> <td>默认。背景颜色是透明的(底层内容会透出来)。</td> </tr> <tr> <td>initial</td> <td>将此属性设置为其默认值。请参阅 <a href="/sw/cssref/css_initial.html" title="Kichwa cha uanzisho wa CSS">initial</a>。</td> </tr> <tr> <td>inherit</td> <td>从其父元素继承此属性。请参阅 <a href="/sw/cssref/css_inherit.html" title="Kichwa cha kusambaa wa CSS">inherit</a>。</td> </tr> </table> </div> <div> <h2>技术细节</h2> <table class="definition-usage"> <tr> <th style="width: 25%;">默认值:</th> <td>transparent</td> </tr> <tr> <th>返回值:</th> <td>字符串,表示背景颜色。</td> </tr> <tr> <th>CSS 版本:</th> <td>CSS1</td> </tr> </table> </div> <div> <h2>浏览器支持</h2> <p><code>backgroundColor</code> 是 CSS1 (1996) 特性。</p> <p>所有浏览器都完全支持它:</p> <table class="browser-support"> <tr> <th class="bsChrome">Chrome</th> <th class="bsEdge">Edge</th> <th class="bsFirefox">Firefox</th> <th class="bsSafari">Safari</th> <th class="bsOpera">Opera</th> <th class="bsIE">IE</th> </tr> <tr> <td>Chrome</td> <td>Edge</td> <td>Firefox</td> <td>Safari</td> <td>Opera</td> <td>IE</td> </tr> <tr> <td>Wahusii</td> <td>Wahusii</td> <td>Wahusii</td> <td>Wahusii</td> <td>Wahusii</td> <td>Wahusii</td> </tr> </table> </div> <div class="prenextnav-ref"> <ul> <li> 上一页 <a href="/sw/jsref/prop_style_backgroundattachment.html" title="Umoja wa msingi wa backgroundAttachment wa Style">backgroundAttachment</a></li> <li> 下一页 <a href="/sw/jsref/prop_style_backgroundimage.html" title="Umoja wa msingi wa backgroundImage wa Style">backgroundImage</a></li> <li> 返回上一层 <a href="/sw/jsref/dom_obj_style.html" title="HTML DOM Style 对象">HTML DOM Style 对象</a></li> </ul> </div><div style="background-color:#fcfdf8; padding:0;"> </div> </div> <!-- maincontent end --> <div id="sidebar"> <div><h3><center> 工具箱 </center><h3> <h5 id="tools_reference"><a href="/sw/jsref/index.html">JavaScript 和 HTML DOM 参考手册</a></h5> <h5 id="tools_example"><a href="/sw/js/js_examples.html">JavaScript 实例</a></h5> <h5 id="tools_quiz"><a href="/sw/js/js_quiz.html">JavaScript 测验</a></h5> <h5 id="tools_tutorial"><a href="/sw/js/index.html">JavaScript 教程</a></h5> </div> <div><h3><center> 赞助商链接 </center><h3> <div id="sbtg"> <script src="/myjs/zzsr.js"></script> </div> </div> </div> <div id="footer"> <p id="p1"> CodeW3C.com 提供的内容仅用于培训和测试,不保证内容的正确性。通过使用本站内容随之而来的风险与本站无关。版权所有,保留一切权利。 </p> <p id="p2"> <a href="/sw/about/index.html" title="Kuhusu CodeW3C.com">Kuhusu CodeW3C.com</a> <a href="/sw/about/about_helping.html" title="Msaada wa CodeW3C.com">Msaada wa CodeW3C.com</a> <a href="/sw/about/about_use.html" title="Kuhusu kutumia">Mshahara wa kutumia</a> <a href="/sw/about/about_privacy.html" title="Kuhusu hitilafu">Mshahara wa hitilafu</a> <a href="http://www.comfortsoftwaregroup.com/" target="_blank"><img src="/comfortsoftwaregroup.png"></a> <a href="http://www.ce4e.com/" target="_blank"><img src="/poweredby.png" alt="Inaripia na Ce4e.com"></a> </p> </div> </div> <!-- wrapper end --> <script src="/myjs/tongji.js"></script> </body> </html>