I was actually amused by the title. The angle of the two sides is not a triangle. Then with regard to your need, take a look at the pseudo-class.
pseudo-class, a:: before, a:: after, you can refer to Baidu News Home the style change of the hover switch button
solid triangle you should know, it is actually two solid triangles, a gray one and a white triangle, and the white triangle blocks the gray triangle. There is only a gray corner border left to OK
https://codepen.io/vizocn/pen.
Thirty guests-set triangles with only two sides in CSS
can be implemented with triangles and two pseudo classes, as shown in the above implementation!
li {
position: relative;
padding: 0.5em 0.75em;
}
li:hover {
font-weight: bold;
cursor: pointer;
}
li:hover::before {
content: '';
position: absolute;
top : 19px;
right : 0;
width: 0;
height: 0;
border-right: 10px solid -sharpccc;
border-top: 5px solid transparent;
border-bottom: 5px solid transparent;
}
li:hover::after {
content: '';
position: absolute;
top : 19px;
right : -2px;
width: 0;
height: 0;
border-right: 10px solid -sharpfff;
border-top: 5px solid transparent;
border-bottom: 5px solid transparent;
}
you can consider using pseudo classes to implement:: before +:: after + location processing
is equivalent to a menu
should be made into one line
the css style name controls the display and hiding of the symbols on the right (plus a class display, otherwise hidden)
if you want to make a slide animation, it is not suitable to do every line. Instead, you should use the mouse event to calculate the corresponding position on the outer layer of the label, and dynamically modify the CSS parameter value
.
to achieve the display style of this element, you can use a DIV, set width and height, as long as two borders, rotate 45 degrees, absolutely locate to the right