CSS(层叠样式表)是一种用于描述HTML或XML(包括SVG、MathML等各种XML方言)文档样式的样式表语言。在CSS中,特殊符号通常用于表示特定的属性值、选择器或伪类。
!important
:用于强制应用某个样式,优先级最高。currentColor
:表示当前元素的文本颜色。inherit
:表示从父元素继承某个属性的值。>
:子选择器,表示直接子元素。+
:相邻兄弟选择器,表示紧邻的兄弟元素。~
:通用兄弟选择器,表示所有兄弟元素。#
:ID选择器,用于选择具有特定ID的元素。.
:类选择器,用于选择具有特定类的元素。:hover
:表示鼠标悬停在元素上时的状态。:active
:表示元素被激活(如按下鼠标)时的状态。:focus
:表示元素获得焦点时的状态。:nth-child()
:表示选择特定顺序的子元素。.container
元素的直接子元素.item
,并设置其宽度为100px。.box
元素上时,将其放大到原来的1.2倍。.child
元素继承.parent
元素的颜色。-webkit-
、-moz-
)或使用Autoprefixer等工具自动添加前缀。<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Special Characters Example</title>
<style>
.container > .item {
width: 100px;
height: 100px;
background-color: red;
}
.box:hover {
transform: scale(1.2);
}
.parent {
color: blue;
}
.child {
color: inherit;
}
</style>
</head>
<body>
<div class="container">
<div class="item"></div>
</div>
<div class="box">Hover me!</div>
<div class="parent">
This is the parent text.
<div class="child">This is the child text.</div>
</div>
</body>
</html>
领取专属 10元无门槛券
手把手带您无忧上云