【前端面试】2. css画三角形、扇形


#triangle{
  width: 0;
   height: 0;
   border-top: 20px solid red;
   border-left: 20px solid pink;
   border-right: 20px solid yellowgreen;
   border-bottom: 20px solid plum;
}
#sector{
   width: 0;
   height: 0;
   border-radius: 50%;
   border-top: 20px solid red;
   border-left: 20px solid pink;
   border-right: 20px solid yellowgreen;
   border-bottom: 20px solid plum;
} 

triangle三角形  sector扇形
例如:
上三角 上扇形:

#triangle{
            width: 0;
            height: 0;
            border-top: 20px solid red;
            border-left: 20px solid transparent;
            border-right: 20px solid transparent;
            border-bottom: 20px solid transparent;
        }
        #sector{
            width: 0;
            height: 0;
            border-radius: 50%;
            border-top: 20px solid red;
            border-left: 20px solid transparent;
            border-right: 20px solid transparent;
            border-bottom: 20px solid transparent;
        } 

triangle三角形  sector扇形
即可。