(〜)是什么意思在CSS

参见英文答案 > What does the “~” (tilde/squiggle/twiddle) CSS selector mean?4个答案我想知道什么(〜)意思在css。
#img1:hover ~ #img2 {
    opacity: 0;
}

在visual studio中,我得到“意想不到的字符序列”的错误,当我使用这个符号。这在CSS中的实际意义是什么。它有什么作用?

解决方法

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.

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>

相关文章

Css3如何实现鼠标移上变长特效?(图文+视频)
css3怎么实现鼠标悬停图片时缓慢变大效果?(图文+视频)
jquery如何实现点击网页回到顶部效果?(图文+视频)
css3边框阴影效果怎么做?(图文+视频)
css怎么实现圆角边框和圆形效果?(图文+视频教程)
Css3如何实现旋转移动动画特效