如何使用 CSS 创建复选标记/勾号

cssweb developmentfront end technology更新于 2024/8/27 16:44:17

我们可以使用 CSS 创建自定义复选标记。以下示例演示了此效果 −

示例

<!DOCTYPE html>
<html>
<style>
div {
   margin: 2%;
   position: relative;
   width: 40px;
   height: 40px;
   box-shadow: inset 0 0 12px lightblue;
}
div::before {
   content: "";
   position: absolute;
   width: 8px;
   top: 50%;
   height: 50%;
   border-radius: 2px;
   background-color: rgb(123,45,20);
   transform: translateX(12px) rotate(-45deg);
   transform-origin: left bottom;
   z-index: +1;
}
div::after {
   content: "";
   position: absolute;
   bottom: 0;
   height: 8px;
   width: 100%;
   border-radius: 2px;
   background-color: rgb(200,52,120);
   transform: translateX(12px) rotate(-45deg);
   transform-origin: left bottom;
}
</style>
<body>
Custom mark!
<div></div>
</body>
</html>

输出

这将产生以下结果 −

示例

<!DOCTYPE html>
<html>
<style>
body {
   padding: 2%;
   text-align: center;
}
div {
   display: inline-block;
   height: 100px;
   width: 35px;
   border-bottom: 10px solid chartreuse;
   border-right: 10px solid chartreuse;
   transform: rotate(45deg);
}
</style>
<body>
<div></div>
</body>
</html>

输出

这将产生以下结果 −


相关文章


有用资源