You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改CSS镜像翻转对勾标记,使其指向正确方向?

问题解决:CSS对勾标记方向修正

问题成因

你当前的对勾是通过.tick:before伪元素的**右下边框(border-width: 0 5px 5px 0)**配合rotate(45deg)实现的,这种组合会生成一个翻转的反向勾,和标准对勾(✓)的方向完全相反。

解决方法

只需修改.tick:before的三个核心属性,就能得到标准对勾:

  • 调整边框显示方向,只保留左下边框:border-width: 0 0 5px 5px;
  • 反转旋转角度:transform: rotate(-45deg);
  • 微调水平定位,让对勾在圆形容器中居中:left: 25px;

修改后的完整代码

CSS部分

body,
html {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f0f8ff;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.container {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  max-width: 600px;
  width: 100%;
}

h2 {
  color: #1F75FE;
  margin-bottom: 20px;
}

p {
  color: #333;
  margin-bottom: 20px;
}

a {
  color: #1F75FE;
  text-decoration: none;
  font-weight: bold;
}

a:hover {
  text-decoration: underline;
}

.tick {
  display: inline-block;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background-color: #d4edda;
  color: #28a745;
  font-size: 40px;
  line-height: 70px;
  margin-bottom: 20px;
  position: relative;
  animation: scale 0.5s ease-in-out forwards;
}

.tick:before {
  content: '';
  position: absolute;
  top: 20px;
  left: 25px; /* 调整定位 */
  width: 30px;
  height: 15px;
  border: solid #28a745;
  border-width: 0 0 5px 5px; /* 修改边框方向 */
  transform: rotate(-45deg); /* 反转旋转角度 */
  opacity: 0;
  animation: fadeIn 0.5s forwards 0.5s;
}

@keyframes scale {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes fadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

HTML部分

<!DOCTYPE html>
<html>

<head>
</head>

<body>
  <div class="container">
    <div class="tick"></div>
    <h2>Order Complete!</h2>
    <p>Your order is completed successfully</p>
  </div>
</body>

</html>

内容的提问来源于stack exchange,提问作者Varun Dubey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 04:02:24