且构网

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

(〜)是什么意思在CSS

更新时间:2023-01-24 12:49:45

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


8.3.2。通用同级组合器



一般的同级组合器由tilde(U + 007E,〜)
字符组成,简单选择器。由两个序列表示的
元素在
文档树***享相同的父元素,并且由第一序列表示的元素
在由
表示的元素之前(不一定立即)第二个。


示例

  h1〜pre 

符合<


< p>函数a(x)必须应用于表中的所有图形。< / p>
< pre> function a(x)= 12x / 13.5< / pre>

还有 + sibling组合器: h1 + pre < pre> 标签必须在< h1>


I want to know what does (~) mean in css.

#img1:hover ~ #img2 {
    opacity: 0;
}

In visual studio, i get 'unexpected character sequence' error when i use this symbol. what is the actual meaning of this in CSS. what does it do?

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

8.3.2. General sibling combinator

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.

example

h1 ~ pre

matches that <pre> here:

<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>

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