在 HTML/CSS 中使用多个 ID 为元素着色
Using Multiple ID in HTML/CSS to color elements
我正在尝试使用它为网格着色窗帘颜色,但它不起作用,我不确定为什么。我认为这可能是格式问题,或者它是否与我在程序中编写的其他内容冲突。
#1a,
#1b,
#1c,
#1d,
#1e,
#2a,
#2b,
#2c,
#2d,
#2e,
#3a,
#3b,
#3c,
#3d,
#3e,
#4a,
#4b,
#4c,
#4d,
#4e,
#5a,
#5b,
#5c,
#5d,
#5e {
color: darkblue;
background-color: darkblue;
}
这只是一个基本但非常常见的 CSS 错误,你看你不能有 ID 或 类 以数字开头,只需更新它们就这么简单。
我还建议您使用 SASS 作为循环,您将能够很容易地生成那种顺序 CSS:
请花点时间通读 CSS W3C 规范:
w3.org/TR/CSS21/syndata.html#characters
In CSS, identifiers (including element names, classes, and IDs in
selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646
characters U+00A0 and higher, plus the hyphen (-) and the underscore
(_); they cannot start with a digit, two hyphens, or a hyphen followed
by a digit. Identifiers can also contain escaped characters and any
ISO 10646 character as a numeric code (see next item). For instance,
the identifier "B&W?" may be written as "B&W?" or "B WF".
我正在尝试使用它为网格着色窗帘颜色,但它不起作用,我不确定为什么。我认为这可能是格式问题,或者它是否与我在程序中编写的其他内容冲突。
#1a,
#1b,
#1c,
#1d,
#1e,
#2a,
#2b,
#2c,
#2d,
#2e,
#3a,
#3b,
#3c,
#3d,
#3e,
#4a,
#4b,
#4c,
#4d,
#4e,
#5a,
#5b,
#5c,
#5d,
#5e {
color: darkblue;
background-color: darkblue;
}
这只是一个基本但非常常见的 CSS 错误,你看你不能有 ID 或 类 以数字开头,只需更新它们就这么简单。
我还建议您使用 SASS 作为循环,您将能够很容易地生成那种顺序 CSS:
请花点时间通读 CSS W3C 规范: w3.org/TR/CSS21/syndata.html#characters
In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, two hyphens, or a hyphen followed by a digit. Identifiers can also contain escaped characters and any ISO 10646 character as a numeric code (see next item). For instance, the identifier "B&W?" may be written as "B&W?" or "B WF".