sdbxpjzq 2019-11-04
本方法参考来源:https://www.jianshu.com/p/9a463d50e441
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>triangleCSS</title> <style> #triangle{ width: 0; height: 0; /*border其实是由三角形不断减小高度变为梯形而成的 平常宽度较小的border是对应三角形的底边 增大border宽度时这个特性将会明显*/ /*border-top: 50px solid blue; border-right: 50px solid red; border-bottom: 50px solid green; border-left: 50px solid yellow;*/ /*单个三角形(但另外三边框对应的三角形仍占据空间)*/ /*border: 50px solid; border-color: transparent transparent red;*/ /*尺寸最小化的三角形*/ border-width: 0 50px 50px; border-style: solid; border-color: transparent transparent red; } </style> </head> <body> <div id="triangle"></div> </body> </html>