From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/css/column_combinator/index.html | 99 ++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 files/zh-cn/web/css/column_combinator/index.html (limited to 'files/zh-cn/web/css/column_combinator/index.html') diff --git a/files/zh-cn/web/css/column_combinator/index.html b/files/zh-cn/web/css/column_combinator/index.html new file mode 100644 index 0000000000..1f665103f0 --- /dev/null +++ b/files/zh-cn/web/css/column_combinator/index.html @@ -0,0 +1,99 @@ +--- +title: Column combinator +slug: Web/CSS/Column_combinator +tags: + - CSS + - 参考 + - 合并器 + - 表格 + - 试验 + - 选择器 + - 需要浏览器的兼容性 +translation_of: Web/CSS/Column_combinator +--- +
{{CSSRef("Selectors")}}{{Draft}}{{SeeCompatTable}}
+ +

通过列合并符 (||)链接两个元素时, 它只会匹配被第二个CSS选择器匹配的元素,且此元素属于被第一个CSS选择器匹配的列元素.

+ +
/* 属于"被选择"列的表单元格 */
+col.selected || td {
+  background: gray;
+}
+
+ +

语法

+ +
column-selector || cell-selector {
+  /* style properties */
+}
+ +

示例

+ +

HTML

+ +
<table border="1">
+  <colgroup>
+    <col span="2"/>
+    <col class="selected"/>
+  </colgroup>
+  <tbody>
+    <tr>
+      <td>A
+      <td>B
+      <td>C
+    </tr>
+    <tr>
+      <td colspan="2">D</td>
+      <td>E</td>
+    </tr>
+    <tr>
+      <td>F</td>
+      <td colspan="2">G</td>
+    </tr>
+  </tbody>
+</table>
+ +

CSS

+ +
col.selected || td {
+  background: gray;
+  color: white;
+  font-weight: bold;
+}
+ +

结果

+ +

{{EmbedLiveSample("Examples", "100%")}}

+ +

规范

+ + + + + + + + + + + + + + + + +
规范状态评论补充
{{SpecName("CSS4 Selectors", "#the-column-combinator", "column combinator")}}{{Spec2("CSS4 Selectors")}}最初的定义.
+ +

浏览器兼容性

+ + + +

{{Compat("css.selectors.column")}}

+ +

相关

+ + -- cgit v1.2.3-54-g00ecf