拾光°
思路是用两个css三角一大一小,小的压住大的丝带就出来了,然后文字逆时针旋转45度就好了
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>css丝带</title>
</head>
<style>
/* 案例1 */
/* 案例1 */
/* 案例1 */
.main {
position: relative;
width: 100px;
height: 50px;
margin: 100px auto 100px;
box-shadow: 1px 1px 30px #ccc;
}
/* 利用css三角 做一个大的蓝色三角 */
.bigTriangle {
height: 0;
width: 0;
border-top: 50px solid rgb(52, 139, 238);
border-right: 50px solid rgb(52, 139, 238);
border-bottom: 50px solid transparent;
border-right: 50px solid transparent;
}
/* 利用css三角 做一个小的白色三角 这就把 梯形显示出来了 */
.smallTriangle {
position: absolute;
top: 0;
left: 0;
height: 0;
width: 0;
border-top: 25px solid #fff;
border-right: 25px solid #fff;
border-bottom: 25px solid transparent;
border-right: 25px solid transparent;
}
/* 斜的文字你时针旋转45度 */
.title {
position: absolute;
top: 8px;
left: -1px;
transform: rotateZ(-45deg);
width: 42px;
color: #fff;
font-size: 12px;
}
</style>
<body>
<div class="main">
<!-- 大三角 -->
<div class="bigTriangle">
<!-- 小三角 -->
<div class="smallTriangle"></div>
<!-- 文字 -->
<span class="title">进行中</span>
</div>
</div>
</body>
</html>
效果如下

直接把一个div旋转 然后overflow: hidden;就好了
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>css丝带</title>
</head>
<style>
.main-2 {
position: relative;
margin: 0 auto;
height: 200px;
width: 500px;
/* 隐藏多出的div */
overflow: hidden;
box-shadow: 1px 1px 30px #ccc;
}
.triangle {
position: absolute;
top: 4.6em;
left: -3.4em;
width: 18em;
height: 2em;
overflow: hidden;
background-color: #dc3545;
box-sizing: content-box;
line-height: 2em;
color: #fff;
font-size: 1em;
text-align: center;
text-decoration: none;
font-weight: bold;
transform: rotate(-45deg);
}
</style>
<body>
<div class="main-2">
<div class="triangle">css丝带</div>
</div>
</body>
</html>
