1. <div class="triangle"></div>

1.倒三角形image.png

  1. .triangle {
  2. width: 0;
  3. height: 0;
  4. border-top: 20px solid #333;
  5. border-left: 20px solid transparent;
  6. border-right: 20px solid transparent;
  7. }

2.正三角形 image.png

  1. .triangle {
  2. width: 0;
  3. height: 0;
  4. border-bottom: 20px solid #333;
  5. border-left: 20px solid transparent;
  6. border-right: 20px solid transparent;
  7. }

3.左边三角形image.png

  1. .triangle {
  2. width: 0;
  3. height: 0;
  4. border-left: 20px solid #333;
  5. border-top: 20px solid transparent;
  6. border-bottom: 20px solid transparent;
  7. }

4.右边三角形image.png

  1. .triangle {
  2. width: 0;
  3. height: 0;
  4. border-right: 20px solid #333;
  5. border-top: 20px solid transparent;
  6. border-bottom: 20px solid transparent;
  7. }

5.直角三角形image.png

  1. .triangle {
  2. width: 0;
  3. height: 0;
  4. border-left: 20px solid #333;
  5. border-top: 20px solid transparent;
  6. }

6.倾斜三角形image.png

  1. .triangle {
  2. width: 0;
  3. height: 0;
  4. border-right: 20px solid #333;
  5. border-top: 20px solid transparent;
  6. border-bottom: 20px solid transparent;
  7. transform: rotate(150deg);
  8. }