css 角标

效果图

代码实现

<div class="container">
  <div class="subscript">
      <!-- 使用背景颜色渐变 -->
    <div class="subscript1"></div>
    <div class="texts">角标1</div>
      <!-- 使用三角形 -->
    <!-- <div class="subscript2"></div>
    <div class="texts">角标2</div> -->
    <!-- 使用矩形旋转,父元素使用 overflow:hidden -->
      <!-- <div class="subscript3"></div>
      <div class="texts">角标3</div> -->
  </div>
</div>

<style lang='scss' scoped>
.container {
  width: 300px;
  height: 200px;
  background: #fff;
  border: 1px solid #888888;
  position: relative;
  border-radius: 10px;
}

.subscript {
  position: absolute;
  top: 0px;
  left: 0px;
  width: 100px;
  height: 100px;
  overflow: hidden;
  border-radius: 10px 0px 0px 0px;
  .subscript1 {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #09a6be 50%, transparent 50%);
  }
  .subscript2 {
    width: 0;
    height: 0;
    border-top: 100px solid #09a6be;
    border-right: 100px solid transparent;
  }
  .subscript3 {
    width: 140px;
    height: 140px;
    margin:-70px -70px;
    background: #09a6be;
    transform: rotateZ(45deg);
  }
}
 .texts {
  position: absolute;
  top: 20%;
  left: 15%;
}
</style>

相关推荐

  1. css的巧妙运用

    2023-12-25 10:44:01       27 阅读
  2. css】html 初始化CSS样式(初学者必看)

    2023-12-25 10:44:01       8 阅读
  3. 【uniapp】uniapp的安卓apk图标设置消息数量

    2023-12-25 10:44:01       15 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-25 10:44:01       14 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-25 10:44:01       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-25 10:44:01       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-25 10:44:01       18 阅读

热门阅读

  1. c语言查找算法

    2023-12-25 10:44:01       39 阅读
  2. 第二章 mysql配置

    2023-12-25 10:44:01       24 阅读
  3. 某大型零售企业薪酬与绩效考核体系项目纪实

    2023-12-25 10:44:01       39 阅读
  4. LeetCode //C - 643. Maximum Average Subarray I

    2023-12-25 10:44:01       40 阅读
  5. 面试经典150题(47-49)

    2023-12-25 10:44:01       26 阅读