且构网

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

CSS中的符号代字号(〜)是什么意思

更新时间:2023-02-20 18:11:08

http://www.w3 .org/TR/selectors/

8.3.2.通用同级组合器

通用的同级组合器由波浪号"(U + 007E,〜)制成 分隔两个简单选择器序列的字符.这 这两个序列代表的元素在 文档树和第一个序列表示的元素 在(不一定是立即)在 第二个.

The general sibling combinator is made of the "tilde" (U+007E, ~) character that separates two sequences of simple selectors. The elements represented by the two sequences share the same parent in the document tree and the element represented by the first sequence precedes (not necessarily immediately) the element represented by the second one.

示例

h1 ~ pre

在此匹配<pre>:

<h1>Definition of the function a</h1>
<p>Function a(x) has to be applied to all figures in the table.</p>
<pre>function a(x) = 12x/13.5</pre>

还有一个+选择器,用于相邻的同级组合器:对于h1 + pre<pre>标记必须紧接在<h1>

There is also + selector, for adjacent sibling combinator: with h1 + pre the <pre> tag would have to be right after <h1>