CSS uses the border-style to write a small triangle, cssborder-style
<!DOCTYPE html>
/* Directly copy the code to verify it in the browser */
<Html>
<Head lang = "en">
<Meta charset = "UTF-8">
<Title> </title>
<Style>
*{
Margin: 0;
Padding: 0;
}
/* Box style */
. Box {
Position: relative;
Margin: 20px auto;
Height: 200px;
Width: 200px;
Background: rgba (0, 0, 0, 0.5 );
}
/* Implement using border-style */
. Drop-down {
Position: absolute;
Top: 10px;
Left: 10px;
Height: 0;
Width: 0;
Border: 3px;
/* The style is top border, right, bottom, left in sequence */
Border-style: solid dashed;
/* If you want to implement a downward triangle, set the upper border to implement the remaining borders as dotted lines and set the color to transparent */
Border-left-color: transparent;
Border-right-color: transparent;
Border-bottom-color: transparent;
Color: # fff;
}
/* Write an example with a triangle to the right */
. Right {
Position: absolute;
Top: 10px;
Left: 30px;
Height: 0;
Width: 0;
Border: 10px;
Border-style: dashed solid;
Border-top-color: transparent;
Border-right-color: transparent;
Border-bottom-color: transparent;
Color: yellowgreen;
}
</Style>
</Head>
<Body>
<! -- First write a box with a black background to compare it with the generated triangle -->
<Div class = "box">
<I class = "drop-down"> </I>
<I class = "right"> </I>
</Div>
</Body>
</Html>