css实现精致的角标

css实现精致的角标

参考:视觉还原小技巧!CSS 实现角标效果

image

纯色角标 -> 有白色到透明渐变的角标 -> 更精致有微弱高光的角标

.ribbon1 {
  margin: 0 60px;
  font-size: 34px;
  line-height: 70px;
  color: #fff;
  text-align: center;
  width: 200px;
  height: 70px;
  /* 透明遮罩+soft-light 给标签打上一层高光 */
  background: linear-gradient(135deg, rgba(255, 255, 255, .4), transparent) #ea3447;
  background-blend-mode: soft-light;
  display: inline-block;
  border-radius: 15px 15px 15px 0;
  position: relative;
}

.ribbon1::after {
  position: absolute;
  content: '';
  clip-path: polygon(0 0, 30px 0, 30px 30px);
  width: 30px;
  height: 30px;
  left: 0;
  bottom: -30px;
  /* 颜色变暗:filter滤镜、半透明遮罩 */
  /* 使用filter滤镜 使颜色变暗 */
  /*filter: brightness(.6);*/
  /* 给颜色上添加一个半透明遮罩实现颜色变暗 */
  background: linear-gradient(rgba(0, 0, 0, .3), rgba(0, 0, 0, .3));
  background-color: inherit; /* 继承 */
}

使用 filter: hue-rotate()色相旋转滤镜,得到更多颜色的角标

image
.ribbon1.hue1{
  filter: hue-rotate(90deg);
}
.ribbon1.hue2{
  filter: hue-rotate(190deg);
}
.ribbon1.hue3{
  filter: hue-rotate(264deg);
}
posted @ 2022-08-05 12:17  shine_lovely  阅读(1559)  评论(0编辑  收藏  举报