纯css画三角形 发表于 2018-07-09 | 分类于 css | 阅读次数: 2018-08-09下午,心情烦躁。。写点css。。 画三角形主要用到了border属性,以及border属性的transparent的值,表示透明。 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>css实现三角形</title></head><style> body{ display: flex; flex-wrap: wrap; } .div-area{ width: 25%; height: 200px; } .triangle-up{ width: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-bottom: 50px solid blue; } .triangle-down{ width: 0; height: 0; border-top: 50px solid blue; border-left: 50px solid transparent; border-right: 50px solid transparent; } .triangle-left{ width: 0; height: 0; border-right: 50px solid blue; border-top: 50px solid transparent; border-bottom: 50px solid transparent; } .triangle-right{ width: 0; height: 0; border-left: 50px solid blue; border-bottom: 50px solid transparent; border-top: 50px solid transparent;; } .triangle-topleft{ width: 0; height: 0; border-top: 100px solid blue; border-right: 100px solid transparent; } .triangle-topright{ width: 0; height: 0; border-top: 100px solid blue; border-left: 100px solid transparent; } .triangle-bottomleft{ width: 0; height: 0; border-bottom: 100px solid blue; border-right: 100px solid transparent; } .triangle-bottomright{ width: 0; height: 0; border-bottom: 100px solid blue; border-left: 100px solid transparent; }</style><body><!--上三角--><div class="div-area"> <p>上三角</p> <div class="triangle-up"></div></div><!--下三角--><div class="div-area"> <p>下三角</p> <div class="triangle-down"></div></div><!--左三角--><div class="div-area"> <p>左三角</p> <div class="triangle-left"></div></div><!--右三角--><div class="div-area"> <p>右三角</p> <div class="triangle-right"></div></div><!--左上三角--><div class="div-area"> <p>左上三角</p> <div class="triangle-topleft"></div></div><!--右上三角--><div class="div-area"> <p>右上三角</p> <div class="triangle-topright"></div></div><!--左下三角--><div class="div-area"> <p>左下三角</p> <div class="triangle-bottomleft"></div></div><!--右下三角--><div class="div-area"> <p>右下三角</p> <div class="triangle-bottomright"></div></div></body></html>