CSS凹进去的三角形怎么做?

3131975015
  • 393

图片上的这种

回复
阅读 2.2k
5 个回答

基本可用的一个实现

https://codepen.io/pantao/pen...

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .steps {
      margin: 0;
      padding: 0;
      list-style-type: none;
    }

    .steps li {
      display: inline-block;
      margin-left: -10px;
    }

    .steps li a {
      display: block;
      padding: 0 30px;
      line-height: 30px;
      text-decoration: none;
      color: #345;
      background-color: #def;
      clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%);
    }

    .steps li a:hover {
      background-color: #9ab;
      color: #def;
    }

    .steps li.current a,
    .steps li.current a:hover {
      background-color: #345;
      color: #def;
    }

    .steps li:first-child {
      margin-left: 0;
    }

    .steps li:first-child a {
      clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%);
      padding-left: 20px;
    }
  </style>
</head>
<body>
  <ul class="steps">
    <li>
      <a href="#" title="Step 1">Step 1</a>
    </li>
    <li>
      <a href="#" title="Step 2">Step 2</a>
    </li>
    <li class="current">
      <a href="#" title="Step 3">Step 3</a>
    </li>
    <li>
      <a href="#" title="Step 4">Step 4</a>
    </li>
  </ul>
</body>
</html>
.box{
    width:100px;
    height: 100px;
    margin: 200px;
    border-top: 4px solid black;
    border-left: 4px solid black;
    transform: rotateZ(135deg);
}

clip-path 随手画。
image.png

借助border做的白边盖住做了一个凹进去的

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>1</title>
  <style>
    .box-wrap{
      width: 100px;
      /* margin-right: 30px; */
      position: relative;
    }
    .box{
      width: 100px;
      height: 30px;
      background-color: #ccc;
      position: relative;
    }
    .box1{
      z-index: 2;
    }
    .box-wrap i{
      width: 22px;
      height: 22px;
      border: 2px solid #fff;
      background-color: #ccc;
      position: absolute;
      right: -14px;
      top: 2px;
      transform: rotate(45deg);
      z-index: 1;
    }
    .fl{
      float: left;
    }
    .fr{
      float: right;
    }
  </style>
</head>

<body>
    <div class="box-wrap fl"><div class="box box1"></div><i></i></div>
    <div class="box-wrap fl"><div class="box box2"></div></div>
</body>
<script>

</script>
</html>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
你知道吗?

宣传栏