css3伪类选择器集合
导读:CSS3伪类选择器是CSS3中的一种选择器集合,它们可以根据元素的特定状态来选择和样式化元素。下面介绍一些常见的CSS3伪类选择器。/* :hover伪类选择器 */a:hover {color: red;}/* :active伪类选择器...
CSS3伪类选择器是CSS3中的一种选择器集合,它们可以根据元素的特定状态来选择和样式化元素。下面介绍一些常见的CSS3伪类选择器。
/* :hover伪类选择器 */a:hover {
color: red;
}
/* :active伪类选择器 */a:active {
color: blue;
}
/* :link伪类选择器 */a:link {
color: green;
}
/* :visited伪类选择器 */a:visited {
color: purple;
}
/* :first-child伪类选择器 */p:first-child {
font-weight: bold;
}
/* :last-child伪类选择器 */p:last-child {
font-style: italic;
}
/* :nth-child伪类选择器 */li:nth-child(even) {
background-color: #f2f2f2;
}
/* :checked伪类选择器 */input[type=radio]:checked+label {
font-weight: bold;
}
:hover伪类选择器用于在鼠标悬停在元素上时应用样式,:active伪类选择器用于在元素被点击时应用样式,:link伪类选择器用于选择未被访问过的链接,:visited伪类选择器用于选择曾被访问过的链接。
:first-child伪类选择器选择某个元素的第一个子元素,:last-child伪类选择器用于选择某个元素的最后一个子元素,:nth-child伪类选择器可用于选择某个元素的特定子元素。
:checked伪类选择器用于选择已被选中的单选框或复选框,通常结合+选择器使用,用于选择选中单选框或复选框后的元素,如标签。
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: css3伪类选择器集合
本文地址: https://pptw.com/jishu/451985.html
