html
<div superscript-title="NEW">角标</div>
/*左上角标签,父元素必须设置position: relative;overflow: hidden;height: 大于120;width: 大于120px;,同时,角标标签内加入属性superscript-title="左上角标签文字内容"*/ [superscript-title]:after { content: attr(superscript-title); position: absolute; top: 5px; left: -45px; width: 120px; height: 20px; font-size: 12px; line-height: 1.6; font-family: 'Microsoft YaHei'; text-align: center; color: white; background: linear-gradient(90deg, orange 0%, orangered 100%); transform: rotate(-45deg); } [superscript-title] { position: relative; overflow: hidden; /* 以下代码可以不要---------------------------------------- */ display: flex; justify-content: center; align-items: center; width: 100px; height: 100px; border-radius: 10px; background-color: #1f75d5; color: white; margin: 10px; }
