代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>京东三角案例</title>
<style>
* {
margin: 0;
padding: 0;
}
.box {
position: relative;
width: 120px;
height: 249px;
background-color: pink;
margin: 100px auto;
}
.sanjiao {
position: absolute;
top: -10px;
right: 0;
width: 0;
height: 0;
line-height: 0;
font-size: 0;
border: 5px solid transparent;
border-bottom-color: red;
}
</style>
</head>
<body>
<div class="box">
<div class="sanjiao"></div>
</div>
</body>
</html>
小米案例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>小米三角案例</title>
<style>
* {
margin: 0;
padding: 0;
}
.box {
position: relative;
width: 200px;
height: 259px;
margin: 50px auto;
background-color: pink;
}
.sanjiao {
position: absolute;
top: 5px;
right: -10px;
width: 0;
height: 0;
line-height: 0;
font-size: 0;
border: 5px solid transparent;
border-left-color: pink;
}
</style>
</head>
<body>
<div class="box">
<div class="sanjiao"></div>
</div>
</body>
</html>