コンビネーター(結合子)
コンビネーター(結合子)は、要素と要素の位置関係によって指定するセレクターである。
- 公式サイト:Selectors Level 3#8 combinators
- 公式サイト:Selectors Level 3#8.1 Descendant combinator
- 公式サイト:Selectors Level 3#8.2 Child combinators
- 公式サイト:Selectors Level 3#8.3. Sibling combinators
- 公式サイト:8.3.1. Next-sibling combinator
- 公式サイト:8.3.2. Subsequent-sibling combinator
- 公式サイト:Selectors Level 4#14. Combinators
- 公式サイト:Selectors Level 4#14.1. Descendant combinator ( )
- 公式サイト:Selectors Level 4#14.2. Child combinator (>)
- 公式サイト:Selectors Level 4#14.3. Next-sibling combinator (+)
- 公式サイト:Selectors Level 4#14.4. Subsequent-sibling combinator (~)
- 公式サイト:Selectors Level 4#15.1. Column combinator (||)
目次
- 子孫結合子
- ソースコードの例
- 説明
- 子結合子
- ソースコードの例
- 説明
- 一般兄弟結合子
- ソースコードの例
- 説明
- 隣接兄弟結合子
- ソースコードの例
- 説明
- KnotTextでのCSSの分類
1. 子孫結合子(Descendant combinator) selector1 selector2
子孫結合子(Descendant combinator)は、selector1に含まれる全てのselector2を指定する。
1-1. ソースコードの例
selector1 selector2 {property: value;}ul li {property: value;}
1-2. 説明
特になし。
2. 子結合子(Child combinator) selector1 > selector2
子結合子(Child combinator)は、selector1に含まれる直下のみのselector2を指定する。
2-1. ソースコードの例
selector1 > selector2 {property: value;}ul > li {property: value;}
2-2. 説明
特になし。
3. 一般兄弟結合子(General sibling combinator) selector1 ~ selector2
一般兄弟結合子(General sibling combinator)は、selector1とselector2が同じ親要素を持っている状態で、selector1に並ぶ全てのselector2を指定する。?曖昧
3-1. ソースコードの例
selector1 ~ selector2 {property: value;}ul ~ li {property: value;}
3-2. 説明
特になし。
4. 隣接兄弟結合子(Adjacent sibling combinator) selector1 + selector2
隣接兄弟結合子(Adjacent sibling combinator)は、selector1とselector2が同じ親要素を持っている状態で、selector1の直後に並ぶselector2を指定する。?曖昧
4-1. ソースコードの例
selector1 + selector2 {property: value;}ul + li {property: value;}
4-2. 説明
特になし。
備考 Column combinator 列結合子と呼ばれる実験的なやつは対応なしなので扱わない
ul || li {property: value;}
名前を"subsequent-sibling combinator"に変更
隣接兄弟(Adjacent sibling)結合子 p + a (仕様ではNext-sibling combinator)
一般兄弟(General sibling)結合子 p ~ a (仕様ではSubsequent-sibling combinator)
5. KnotTextでのCSSの分類
2-1. CSSセレクター
2-1-1. ベーシックセレクター
| ユニバーサルセレクタ― | * { } |
|---|---|
| タイプセレクタ― | element { } |
| クラスセレクタ― | .classname { } |
| IDセレクター | #idname { } |
| 属性セレクタ― | selector[attribute] { } |
| セレクターリスト | div, p { } |
|---|
2-1-3. コンビネーター(結合子)
| 子孫結合子 | div a |
|---|---|
| 子結合子 | div > a |
| 一般兄弟結合子 | p ~ a |
| 隣接兄弟結合子 | p + a |
2-1-4. 疑似クラスと疑似要素
| 疑似クラス | div:hover { } |
|---|---|
| 疑似要素 | div::before { } |
2-2. CSSプロパティ
| 3D | perspective, backface-visibilityなど | |
|---|---|---|
| animation | animation, transform, transitionなど | |
| boxmodel | outline, margin, border, padding, background, overflow, z-index, height, width, positionなど | |
| counter | counter-increment, counter-reset, counter-setなど | |
| custom | --* | |
| element | box-shadow, box-sizing, object-fit, object-position, opacity, mix-blend-mode, visibility, content, display, text-overflow, float, clear, empty-cells, caption-side, list-styleなど | |
| graphics | backdrop-filter, filter, shape-image-threashold, shape-margin, scale, image-rendering, aspect-ratio, mask, clip, clip-path, inset, outsetなど | |
| internationalization | line-break, writing-mode, text-orientation, text-combine-upright, direction, unicode-bidi, block-size, inline-sizeなど | |
| layout | column-rule, flex, grid, align-content, align-items, align-self, align-tracks, justify-content, justify-items, justify-self, order, column-count, column-fill, column-gap, columns, column-span, column-width, gap, row-gap, place-content, place-items, place-self, vertical-alignなど | |
| performance | forced-color-adjust, text-rendering, content-visibility, will-change, color-scheme, contain, color-adjustなど | |
| text | word-spacing, text-shadow, text-transform, text-underline-offset, text-underline-position, white-space, shape-outside, text-align, text-align-last, text-indent, text-justify, letter-spacing, line-height, line-height-step, widows, word-break, word-wrap, color, hanging-punctuation, hyphens, initial-letter, orphans, quotes, font, text-decoration, text-emphasis, break-after, break-before, break-insideなど | |
| user-interface | scroll-margin, scroll-padding, overscroll-behavior, user-select, touch-action, caret-color, cursor, resize, pointer-events, scrollbar-color, scrollbar-gutter, scrollbar-width, scroll-behavior, scroll-snap-align, scroll-snap-typeなど | |
| その他のCSSプロパティ | ||
2-3. CSSプロパティの値
| Length | px pt vh... |
|---|---|
| inherit, unset... | |
| !important | |
| Functions | attr(), calc(), clamp(), max(), min()... |
| Angle | deg, grad, rad, turn... |
| Resolution | dpi, dpcm, dppx, x... |
| Time | s, ms... |
| Frequency | Hz, kHz... |
| その他の値 | |
2-4. @ルール
| @font-face | Webフォント |
|---|---|
| @namespace | |
| @media | @media(min-width: 540px) { } |
| @supports | |
| @charset | @charset 'utf-8'; |
| @page | |
| @counter-style | |
| @color-profile | |
| @keyframes | |
| その他の@ルール | |
W3C CSS Validation Service は CSS が正しく書かれているかを判定するために利用できます。デバッグのために重宝するツールです。