image.png
    实现:

    1. <style>
    2. div {
    3. position: relative;
    4. width: 300px;
    5. height: 40px;
    6. margin: 200px auto;
    7. border: 1px solid #bfbfbf;
    8. }
    9. /* 三角形用伪元素做*/
    10. div::after {
    11. position: absolute;
    12. top: 13px;
    13. right: 10px;
    14. content: '';
    15. width: 10px;
    16. height: 10px;
    17. border-right: 2px solid #bdbdbd;
    18. border-bottom: 2px solid #bdbdbd;
    19. transform: rotate(45deg);
    20. transition: 0.3s;
    21. }
    22. div:hover::after{
    23. transform: rotate(225deg);
    24. }
    25. </style>
    26. </head>
    27. <body>
    28. <div></div>
    29. </body>