利用CSS3画图
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <style> #hei { width: 100px; height: 90px; /* background-color: aqua; */ margin: auto; position: relative; } //在hei的左右添加伪元数 #hei:before, #hei:after { content: ""; width: 50px; height: 80px; background-color: red; position: absolute; //border-radius 属性是一个简写属性,用于设置四个 border-*-radius 属性 border-radius: 25px 25px 0 0; //先右旋转45度 transform: rotate(45deg); //从那个点开始旋转 transform-origin: 100% 100%; } #hei::after { left: 50px; transform: rotate(-45deg); transform-origin: 0 100%; } #sanjiao{ width: 0px; border: 20px solid red; //transparent透明 border-color: brown transparent transparent transparent; transform: rotate(180deg); } </style> <body> <div id="hei"> </div> <div id="sanjiao"> </div> </body> </htm
盒子模式