<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
width: 0;
height: 0;
border:50px solid transparent;
border-right: 50px solid red;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
The core code is border: 50px solid transparent; border-right: 50px solid red; the triangle direction is left;
You can set border-left, border-top, border-bottom to control the orientation of the triangle;
In development, triangles can be set for the before or after pseudo-elements of a box to form a shape of dialogue information. Used with absolute positioning.
Pseudo elements are inline elements and need to be converted
.tip::before {
position: absolute;
top: 11px;
left: -12px;
display: inline-block;
content: '';
width: 0px;
height: 0px;
border: 6px solid transparent;
border-right: 6px solid #ccc;
}