zl程序教程

您现在的位置是:首页 >  前端

当前栏目

css——三角标签实现

CSS 实现 标签 三角
2023-09-27 14:29:10 时间

参考:https://blog.csdn.net/whqet/article/details/8881957

 

效果:

 

 

 

 

html:

 <span class="s-triangle"><i class="triangelTag">9.0折</i></span>

 

css:

.s-triangle {
  display: inline-block;
  font-size:12px;
  margin-left: 15px;
  position: relative;
}

.triangelTag {
  display: block;
  background-color: #ffdd00;
  height: 20px;
  line-height: 20px;
  padding: 0 10px 0 12px;
  position: relative;
}

.triangelTag:before {
  content: " ";
  width: 0px;
  height: 0px;
  position: absolute;
  top: 0;
  left: -20px;
  border: 10px solid transparent;
  border-right-color: #ffdd00;
}