CSS: pseudo-classes and pseudo-elements 1.Definition: pseudo-classes The pseudo-class concept is introduced to permit selection based on information that lies outside of the document tree or that cannot be expressed using the other simple selectors. In Chinese:引入伪类概念是为了允许基于文档树之外的...
并且,一些伪元素可以使开发者获取到不存在于源文档中的内容(比如常见的::before,::after)。 伪元素的由两个冒号::开头,然后是伪元素的名称。 使用两个冒号::是为了区别伪类和伪元素(CSS2中并没有区别)。当然,考虑到兼容性,CSS2中已存的伪元素仍然可以使用一个冒号:的语法,但是CSS3中新增的伪元素必须使用两...
CSS伪类选择器根据其他条件匹配组件,而不一定由文档树定义。CSS 伪类 是添加到选择器的关键字,指定要选择的元素的特殊状态。 一、什么是伪类? CSS伪类允许设置元素的动态状态的样式,例如悬停,活动状态和焦点状态,以及文档树中现有但不能通过使用其他选择器作为目标的元素,而无需添加任何选择器它们的ID或类。 例如,...
CSS伪类是用来添加一些选择器的特殊效果。 语法 伪类的语法: selector : pseudo - class { property : value ;} 复制 CSS类也可以使用伪类: selector . class : pseudo - class { property : value ;} 复制 anchor伪
CSS Pseudo-elements 伪元素是一个附加至选择器末的关键词,允许对被选择元素的特定部分修改样式。CSS伪元素是一种样式化文档元素的方法,这些元素没有由文档树中的位置明确定义。
This can only be used with block-level elements. background properties font properties text-decoration color properties word-spacing letter-spacing text-transform vertical-align line-height clear Ex: – p::first-line { color: red;} ::selection- This is used to matches the portion of an ...
CSS 2.1 Selectors, Pseudo-Classes, and Pseudo-Elements: Appendix C - CSS Cookbook, Third EditionChristopher Schmitt
CSS - The :lang Pseudo-class The:langpseudo-class allows you to define special rules for different languages. In the example below,:langdefines the quotation marks for elements with lang="no": Example q:lang(no) { quotes: "~" "~"; } ...
三、伪类和CSS类 伪类可以与CSS类结合使用。 在下面的示例中class="red",带有的链接将显示为红色。 <!DOCTYPE html>使用带有选择器的CSS伪类示例a.red:link{color:#ff0000;}Click meClick me 四、总结 本文基于CSS基础,介绍了CSS中的伪类,从什么是伪类,常见的伪类的用法( first-child,: last-seudo,: nth...
The double colon replaced the single-colon notation for pseudo-elements in CSS3. This was an attempt from W3C to distinguish betweenpseudo-classesandpseudo-elements. The single-colon syntax was used for both pseudo-classes and pseudo-elements in CSS2 and CSS1. ...