转载自 http://www.daqianduan.com/4721.html
<html>
<head>
<meta charset="UTF-8">
<title>创建三角形(小三角)的几种方法title>
head>
<body>
<h1 class="demo-title">创建三角形(小三角)的几种方法h1>
<div class="demo-container demo">
<style>
body {
font: normal small Arial, Helvetica;
text-align: center;
}
.border-triangle {
border-color: #57af1a #fff #fff #fff;
border-style: solid;
border-width: 100px 60px 0 60px;
height: 0;
width: 0;
display: inline-block;
/* demo */
}
.entity-triangle {
font-size: 12em;
line-height: .7;
color: #f7931d;
text-shadow: 0 7px 7px rgba(0, 0, 0, .5);
}
.rotated-triangle {
width: 100px;
height: 100px;
margin: 0 auto;
/* demo */
position: relative;
overflow: hidden;
}
.rotated-triangle:after {
content: "";
position: absolute;
top: -35px;
left: 15px;
width: 65px;
height: 65px;
border: 2px solid #ce0f3d;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
background-color: #f21972;
background-image: -webkit-gradient(linear, left top, left bottom, from(#f21972), to(#e80f43));
background-image: -webkit-linear-gradient(top, #f21972, #e80f43);
background-image: -moz-linear-gradient(top, #f21972, #e80f43);
background-image: -o-linear-gradient(top, #f21972, #e80f43);
background-image: linear-gradient(to bottom, #f21972, #e80f43);
-webkit-box-shadow: 0 -1px 0 rgba(255, 255, 255, .7) inset, -1px 0 0 rgba(255, 255, 255, .7) inset;
box-shadow: 0 -1px 0 rgba(255, 255, 255, .7) inset, -1px 0 0 rgba(255, 255, 255, .7) inset;
}
.svg-triangle {
margin: 0 auto;
width: 100px;
height: 100px;
}
.svg-triangle polygon {
fill: #98d02e;
stroke: #65b81d;
stroke-width: 2;
}
/* --------------- */
#about {
color: #444;
}
#about a {
color: #777;
}
style>
<h3>1、Base64 imageh3>
<img alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHEAAABnCAYAAAA38a1WAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPA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r6XHSCkHLmKnJ17qqCtNtrUBhStdt9QqF3ootV0FGB9L0P0z/h/aqSjgX2PiZnegHGXrAJBSDphoBGwyXa7RYnmE1FbjSwnJheti6qCG/Qu5xiYY+4PlaJSobFUtAOAqC6626B9PX3Jp2alLtExQkaqGsnLJhZ3wCVLHENbkNJRk32LXTqKP1Y5NKYcSSwCusYWgFAlEKUzJhbaejpcD4XD0ry6movzYqQhkJ+UwHlxtUI4xbVhsoX4+OW6iRXKB19MBPh68/MCSDljr/oV3KirQUQOik7ndj5RDvUVOKeTOqm9kWMQdWwGXbgIKnzSOtmvzgjl+ZilKvwmHoX91yhMroBz0o3JzKGEx6qq4OJ4Ye4nx4cyRd+f2bFclF/S6axKocjH1kdyqdqKC+A7dnPZXY79v0TavB1er3LFzxT+2ydk+Y7VjRXvgJEboVwunrMKOdqnMqBQS/1bQx+9kDwXZ39iTHLYrjlpfVXciqzmE15gz271t6bOtP7vzz1xD87dKDsx39u3Z8JzmQM+xcDj7FAonjnBopcMqdijT9c6rh1D7A8pQk6nLrhoz+PHu8wQlCfTBInURTod7c3lwNSlzxGuMZeTBvl7kQFzNyWqNFD8FvhZ3hMTqkxxWaxBYn4FMa3YqfvByhMTaoREA++cdG5mq1rI2Y2HZkl2j1YGjHYl0AYAhuKSsJznUPplA7qgPo6MaiTZoJJMcO/ExSerFekhm6sKJHkmOSDnNripTFyish3BKJzkMMNcUA8B6B6dt/Wu0o3DUI9EhyVEItMlUU+rNgXXhRBtn0CFWoZxXVw6sp3Ba5hTi0bmg3pxGb/8XYADcXqq0m1KMewAAAABJRU5ErkJggg==">
<br><br>
<h3>2、Borderh3>
<span class="border-triangle">span>
<br><br>
<h3>3、Entityh3>
<span class="entity-triangle">▼span>
<br><br>
<h3>4、Rotatedh3>
<div class="rotated-triangle">div>
<h3>5、Canvash3>
<canvas id="triangle" height="100" width="100">Trianglecanvas>
<script>
var canvas = document.getElementById('triangle');
var context = canvas.getContext('2d');
context.beginPath();
context.moveTo(0, 0);
context.lineTo(100, 0);
context.lineTo(50, 100);
context.closePath();
context.fillStyle = "rgb(78, 193, 243)";
context.fill();
script>
<br><br>
<h3>6、SVGh3>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" class="svg-triangle">
<polygon points="0,0 100,0 50,100">polygon>
svg>
div>
body>
html>