CSS中划线通常是指在文本上添加一条线,这种效果可以通过多种CSS属性实现,最常见的是使用text-decoration属性。
text-decoration: line-through;border、box-shadow等属性创建自定义样式的划线。<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS中划线示例</title>
<style>
.line-through {
text-decoration: line-through;
color: #333;
}
.custom-line {
position: relative;
display: inline-block;
}
.custom-line::after {
content: '';
position: absolute;
left: 0;
right: 0;
top: 50%;
height: 2px;
background-color: red;
}
</style>
</head>
<body>
<p class="line-through">这是带有删除线的文本</p>
<p class="custom-line">这是带有自定义划线的文本</p>
</body>
</html>text-decoration属性的值正确设置为line-through。text-decoration-skip-ink属性调整划线跳过的区域。::before或::after来精确控制划线的位置。通过以上方法,可以有效地解决CSS中划线的相关问题,并实现各种自定义效果。
没有搜到相关的沙龙