且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是background-color:none有效的CSS吗?

更新时间:2023-11-26 18:46:58

$ c> transparent $ c>作为 none 不是有效的 background-color p>

CSS 2.1规范 background-color 属性指定以下内容:


值:< color> |透明|继承


< color> 关键字或颜色的数字表示。 有效的颜色关键字是:


aqua,黑色,蓝色,紫红色,灰色,绿色,紫色,红色,银色,蓝绿色,白色和黄色


transparent inherit 是有效的关键字,但 none 不是。


Can anyone tell me if the following CSS is valid?

.class {
    background-color:none;
}

You probably want transparent as none is not a valid background-color value.

The CSS 2.1 spec states the following for the background-color property:

Value: <color> | transparent | inherit

<color> can be either a keyword or a numerical representation of a colour. Valid color keywords are:

aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, orange, purple, red, silver, teal, white, and yellow

transparent and inherit are valid keywords in their own right, but none is not.