css 右上角三角形标签样式

<style>
.box{
position: relative;
height: 100px;
width: 300px;
border: 1px solid gray;
box-sizing: border-box;
}
.sanjiao{
position: absolute;
top: 0;
right: 0;
height: 60px;
width: 60px;
background-color: red;
clip-path: polygon(0 0, 100% 100%,100% 0);
}
.sanjiao-text{
position: absolute;
top: 0;
right: 0;
z-index: 4;
color: #fff;
transform: rotate(45deg);
transform-origin: 0 50%;

}
</style>

</head>
<body>
<div class="box">
<div class="sanjiao"></div>
<div class="sanjiao-text">封存</div>
</div>
</body>

 

 

.sanjiao{
position: absolute;
top: 0;
right: 0;
height: 60px;
width: 60px;
background-color: red;
clip-path: polygon(0 0, 100% 100%,100% 0);
}
.sanjiao-text{
position: absolute;
top: 0;
right: 0;
z-index: 4;
color: #fff;
transform: rotate(45deg);
transform-origin: 50% 50%;
height: 60px;
width: 60px;
text-align: center;
line-height: 30px;
white-space: nowrap;

}

posted on 2023-08-21 13:57  zyp_java_net  阅读(454)  评论(0编辑  收藏  举报

导航