这是代码,有人能解释一下它是如何工作的吗?
.top-2\.5{
top:0.625rem;
}
.top-1\/2{
top:50%;
}发布于 2022-09-24 08:11:37
\用作转义序列。请参考这了解更多信息。
这些CSS类名可以在HTML标记中引用,如下所示:
<body>
<h1 class = "top-1/2">My First Heading</h1>
<p class = "top-2.5">My first paragraph.</p>
</body>完整代码参考:
<!DOCTYPE html>
<html>
<head>
<style>
.top-2\.5{
top:0.625rem;
color: red;
}
.top-1\/2{
top:50%;
color: blue;
}
</style>
<title>Page Title</title>
</head>
<body>
<h1 class = "top-1/2">My First Heading</h1>
<p class = "top-2.5">My first paragraph.</p>
</body>
</html>https://stackoverflow.com/questions/73835500
复制相似问题