背景色

CSS在处理每个HTML元素时都be假设它们位于一个无形的盒子中,而background-color属性设置的正是这个盒子的

背景色。

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
         <style>
             body {
                 background-color: rgb(200,200,200);
             }
             h1 {
                 background-color:DarkCyan;
             }
             h2 {
                 background-color:#ee3e80;
             }
             p {
                 background-color: white
             }
        </style>
    </head>
    <body>
        <div>背景色</div>
        <h1>可使用与指定前景色同样的三种方式来指定背景色:RGB值,十六进制编码和颜色名称。</h1>
        <h2>如果未指定背景色,那么背景将是透明的</h2>
        <p>默认情况下,多数浏览器窗口都是白色背景,但浏览器使用者可以自定义窗口的背景色,因此如果想要确保浏览器窗口是白色背景你可以利用
    <body>元素的background-color属性。</p>
    </body>
</html>
原文地址:https://www.cnblogs.com/q2546/p/9417815.html