
<!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>
<style>
.sj {
position: absolute;
/* -20是border的两倍 */
top: -20px;
right: 10px;
0;
height: 0;
border: 10px solid transparent;
border-bottom-color: pink;
/* 为了照顾兼容性 */
line-height: 0;
font-size: 0;
}
.box {
position: relative;
100px;
height: 100px;
background-color: gray;
margin: 100px auto;
}
</style>
</head>
<body>
<div class="box">
<div class="sj"></div>
</div>
</body>
</html>