css makes the triangle of the navigation bar

When making web pages, we usually see such a demand (make a triangle).
Insert picture description here
First of all

    .box{
    
    
    width: 0;
    height: 0;
    border: 50px solid ;
    border-color: #000 #FF0000 #FFFF00 #00FFFF;
}
    </style>

</head>
<body >
 
    <div class="box"></div>
    
</body>

Insert picture description here
If you need that, just hide the other three

    .box{
    width: 0;
    height: 0;
    border: 50px solid ;
    border-color: #000 transparent transparent transparent;
}
    </style>

</head>
<body >
 
    <div class="box"></div>

Insert picture description here
There is also this kind of demand.
Insert picture description here
This kind of triangle arrow is very common in web pages.

  • Use & gt; & lt; to make and then rotate according to the situation
  • Directly upload the icon (direct to lconfont-Alibaba vector icon library to download)
        .b{
    
    
        
            font-weight: bold;
            position: absolute;
            transform: rotate(90deg);
        }

    </style>

</head>
<body > 
    <div class="b">&gt;</div>
</body>

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_41309350/article/details/114377004