CSS3制作各种形状图像
1、制作圆形:要使用CSS来制作一个圆形,我们需要一个div,被给它设置一个ID<div id="circle"></div>圆形在设置CSS时要设置宽度和高度相等,然后设置border-radius属性为宽度或高度的一半即可:#circle {width: 120px;height: 120px;background: #7fee1d;-moz-border-radius: 60px;-webkit-border-radius: 60px;border-radius: 60px;}

3、制作三角形:要创建一个CSS三角形,需要使用border,通过设置不同边的透明效果,我们可以制作出三角形的现状。另外,在制作三角形时,宽度和高度要设置为0。<div id="triangle"></div> #triangle {width: 0;height: 0;border-bottom: 140px solid #fcf921;border-left: 70px solid transparent;border-right: 70px solid transparent;}

7、制作梯形:梯形是三角形的一个变体,设置CSS梯形时,左右两条边设置为相等,并且给它设置一个宽度。#trapezium {height: 0;width: 120px;border-bottom: 120px solid #ec3504;border-left: 60px solid transparent;border-right: 60px solid transparent;}
8、制作平行四边形:平行四边形的制作方式是使用transform属性使长方形倾斜一个角度。#parallelogram {width: 160px;height: 100px;background: #8734f7;-webkit-transform: skew(30deg);-moz-transform: skew(30deg);-o-transform: skew(30deg);transform: skew(30deg);}

11、六边形:六边形的制作方法可以有很多种,可以像五边形一样,先制作一个长方形,然后在它的上面和下面各放置一个三角形。#hexagon { width: 100px; height: 55px; background: #fc5e5e; position: relative; margin: 10px auto;}#hexagon:before { content: ""; width: 0; height: 0; position: absolute; top: -25px; left: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-bottom: 25px solid #fc5e5e;}#hexagon:after { content: ""; width: 0; height: 0; position: absolute; bottom: -25px; left: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-top: 25px solid #fc5e5e;}

13、蛋形:蛋形时椭圆形的一个变体,它的高度要比宽度稍大,并且设置正确的border-radius属性即可以制作出一个蛋形。#egg {width: 136px;height: 190px;background: #ffc000;display: block;-webkit-border-radius: 63px 63px 63px 63px / 108px 108px 72px 72px;border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;}

15、消息提示框:消息提示框可以先制作一个圆角矩形,然后在需要的地方放置一个三角形。#comment_bubble { width: 140px; height: 100px; background: #088cb7; position: relative; -moz-border-radius: 12px; -webkit-border-radius: 12px; border-radius: 12px;}#comment_bubble:before { content: ""; width: 0; height: 0; right: 100%; top: 38px; position: absolute; border-top: 13px solid transparent; border-right: 26px solid #088cb7; border-bottom: 13px solid transparent;}
