CSS ribbon with inside arrow on the right

后端 未结 2 1221
南方客
南方客 2020-12-10 21:18

I want to create a ribbon effect like on this image (the red part of image): \"ribbon

When I try to c

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-10 22:01

    you could also use a skewed element if this was required for hit-testing as well.

    Something like:

    .rib {
      margin-left: 20px;
      height: 40px;
      width: 200px;
      position: relative;
      background: gray;
      color: white;
      line-height: 40px;
      text-align: center;
    }
    .rib:before,
    .rib:after {
      content: "";
      position: absolute;
      right: -10px;
      top: 0;
      height: 50%;
      width: 40px;
      background: inherit;
    }
    .rib:before {
      transform: skewX(-45deg);
    }
    .rib:after {
      transform: skewX(45deg);
      top: 50%;
    }
    .shad {
      position: absolute;
      height: 40px;
      width: 20px;
      top: 0%;
      left: 0;
      background: dimgray;
      transform-origin: top left;
      transform: skewY(45deg);
      z-index: -1;
      box-shadow:inset 0 0 10px black;
    }
    123

提交回复
热议问题