首页  >  文章  >  web前端  >  css3制作各类图形(一)

css3制作各类图形(一)

WBOY
WBOY原创
2016-09-05 08:45:381211浏览

1、Square

 

<span style="color: #800000;">#square </span>{<span style="color: #ff0000;"> <br>width</span>:<span style="color: #0000ff;"> 100px</span>;<span style="color: #ff0000;"> <br>height</span>:<span style="color: #0000ff;"> 100px</span>;<span style="color: #ff0000;"> <br>background</span>:<span style="color: #0000ff;"> red</span>; }

 

2、Rectangle

 

<span style="color: #800000;">#rectangle </span>{<span style="color: #ff0000;"> <br>width</span>:<span style="color: #0000ff;"> 200px</span>;<span style="color: #ff0000;"> <br>height</span>:<span style="color: #0000ff;"> 100px</span>;<span style="color: #ff0000;"> <br>background</span>:<span style="color: #0000ff;"> red</span>; }

3、Circle

 

<span style="color: #800000;">#circle </span>{<br><span style="color: #ff0000;"> width</span>:<span style="color: #0000ff;"> 100px</span>;<span style="color: #ff0000;"> <br>height</span>:<span style="color: #0000ff;"> 100px</span>;<span style="color: #ff0000;"> <br>background</span>:<span style="color: #0000ff;"> red</span>;<span style="color: #ff0000;"> <br>-moz-border-radius</span>:<span style="color: #0000ff;"> 50px</span>;<span style="color: #ff0000;"> <br>-webkit-border-radius</span>:<span style="color: #0000ff;"> 50px</span>;<span style="color: #ff0000;"> border-radius</span>:<span style="color: #0000ff;"> 50px</span>; }<br> <span style="color: #008000;">/*</span><span style="color: #008000;"> Cleaner, but slightly less support: use "50%" as value </span><span style="color: #008000;">*/</span>

4、Oval

 

<span style="color: #800000;">#oval </span>{<span style="color: #ff0000;"> <br>width</span>:<span style="color: #0000ff;"> 200px</span>;<span style="color: #ff0000;"> <br>height</span>:<span style="color: #0000ff;"> 100px</span>;<span style="color: #ff0000;"> <br>background</span>:<span style="color: #0000ff;"> red</span>;<span style="color: #ff0000;"> <br>-moz-border-radius</span>:<span style="color: #0000ff;"> 100px / 50px</span>;<span style="color: #ff0000;"> <br>-webkit-border-radius</span>:<span style="color: #0000ff;"> 100px / 50px</span>;<span style="color: #ff0000;"> <br>border-radius</span>:<span style="color: #0000ff;"> 100px / 50px</span>; } <br><span style="color: #008000;">/*</span><span style="color: #008000;"> Cleaner, but slightly less support: use "50%" as value </span><span style="color: #008000;">*/</span>

5、Triangle Up

 

<span style="color: #800000;">#triangle-up </span>{<span style="color: #ff0000;"> <br>width</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>height</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>border-left</span>:<span style="color: #0000ff;"> 50px solid transparent</span>;<span style="color: #ff0000;"> <br>border-right</span>:<span style="color: #0000ff;"> 50px solid transparent</span>;<span style="color: #ff0000;"> <br>border-bottom</span>:<span style="color: #0000ff;"> 100px solid red</span>; }

 

6、Triangle Down

 

<span style="color: #800000;">#triangle-down </span>{<span style="color: #ff0000;"> <br>width</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>height</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>border-left</span>:<span style="color: #0000ff;"> 50px solid transparent</span>;<span style="color: #ff0000;"> <br>border-right</span>:<span style="color: #0000ff;"> 50px solid transparent</span>;<span style="color: #ff0000;"> <br>border-top</span>:<span style="color: #0000ff;"> 100px solid red</span>; }

7、Triangle Left

 

<span style="color: #800000;">#triangle-left </span>{<span style="color: #ff0000;"> <br>width</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>height</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>border-top</span>:<span style="color: #0000ff;"> 50px solid transparent</span>;<span style="color: #ff0000;"> <br>border-right</span>:<span style="color: #0000ff;"> 100px solid red</span>;<span style="color: #ff0000;"> <br>border-bottom</span>:<span style="color: #0000ff;"> 50px solid transparent</span>; }

8、Triangle Right

<span style="color: #800000;">#triangle-right </span>{<span style="color: #ff0000;"> <br>width</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>height</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>border-top</span>:<span style="color: #0000ff;"> 50px solid transparent</span>;<span style="color: #ff0000;"> <br>border-left</span>:<span style="color: #0000ff;"> 100px solid red</span>;<span style="color: #ff0000;"> <br>border-bottom</span>:<span style="color: #0000ff;"> 50px solid transparent</span>; }

9、Triangle Top Left

 

<span style="color: #800000;">#triangle-topleft </span>{<span style="color: #ff0000;"> <br>width</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>height</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>border-top</span>:<span style="color: #0000ff;"> 100px solid red</span>;<span style="color: #ff0000;"> <br>border-right</span>:<span style="color: #0000ff;"> 100px solid transparent</span>; }

10、Triangle Top Right

 

<span style="color: #800000;">#triangle-topright </span>{<span style="color: #ff0000;"> <br>width</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>height</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>border-top</span>:<span style="color: #0000ff;"> 100px solid red</span>;<span style="color: #ff0000;"> <br>border-left</span>:<span style="color: #0000ff;"> 100px solid transparent</span>; }

11、Triangle Bottom Left

 

<span style="color: #800000;">#triangle-bottomleft </span>{<span style="color: #ff0000;"> <br>width</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>height</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>border-bottom</span>:<span style="color: #0000ff;"> 100px solid red</span>;<span style="color: #ff0000;"> <br>border-right</span>:<span style="color: #0000ff;"> 100px solid transparent</span>; }

12、Triangle Bottom Right

 

<span style="color: #800000;">#triangle-bottomright </span>{<span style="color: #ff0000;"> <br>width</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>height</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>border-bottom</span>:<span style="color: #0000ff;"> 100px solid red</span>;<span style="color: #ff0000;"> <br>border-left</span>:<span style="color: #0000ff;"> 100px solid transparent</span>; }

13、Curved Tail Arrow

 

<span style="color: #800000;">#curvedarrow </span>{<span style="color: #ff0000;"> <br>position</span>:<span style="color: #0000ff;"> relative</span>;<br><span style="color: #ff0000;"> width</span>:<span style="color: #0000ff;"> 0</span>;<br><span style="color: #ff0000;"> height</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> border-top</span>:<span style="color: #0000ff;"> 9px solid transparent</span>;<br><span style="color: #ff0000;"> border-right</span>:<span style="color: #0000ff;"> 9px solid red</span>;<span style="color: #ff0000;"> <br>-webkit-transform</span>:<span style="color: #0000ff;"> rotate(10deg)</span>;<br><span style="color: #ff0000;"> -moz-transform</span>:<span style="color: #0000ff;"> rotate(10deg)</span>;<span style="color: #ff0000;"> <br>-ms-transform</span>:<span style="color: #0000ff;"> rotate(10deg)</span>;<br><span style="color: #ff0000;"> -o-transform</span>:<span style="color: #0000ff;"> rotate(10deg)</span>; <br>}<span style="color: #800000;"> <br>#curvedarrow:after </span>{<span style="color: #ff0000;"> <br>content</span>:<span style="color: #0000ff;"> ""</span>;<span style="color: #ff0000;"> <br>position</span>:<span style="color: #0000ff;"> absolute</span>;<br><span style="color: #ff0000;"> border</span>:<span style="color: #0000ff;"> 0 solid transparent</span>;<span style="color: #ff0000;"> <br>border-top</span>:<span style="color: #0000ff;"> 3px solid red</span>;<span style="color: #ff0000;"> <br>border-radius</span>:<span style="color: #0000ff;"> 20px 0 0 0</span>;<span style="color: #ff0000;"> <br>top</span>:<span style="color: #0000ff;"> -12px</span>;<span style="color: #ff0000;"> <br>left</span>:<span style="color: #0000ff;"> -9px</span>;<span style="color: #ff0000;"> <br>width</span>:<span style="color: #0000ff;"> 12px</span>;<span style="color: #ff0000;"> <br>height</span>:<span style="color: #0000ff;"> 12px</span>;<span style="color: #ff0000;"> <br>-webkit-transform</span>:<span style="color: #0000ff;"> rotate(45deg)</span>;<span style="color: #ff0000;"> <br>-moz-transform</span>:<span style="color: #0000ff;"> rotate(45deg)</span>;<span style="color: #ff0000;"> <br>-ms-transform</span>:<span style="color: #0000ff;"> rotate(45deg)</span>;<span style="color: #ff0000;"> <br>-o-transform</span>:<span style="color: #0000ff;"> rotate(45deg)</span>; }

14、Trapezoid

 

<span style="color: #800000;">#trapezoid </span>{<span style="color: #ff0000;"> <br>border-bottom</span>:<span style="color: #0000ff;"> 100px solid red</span>;<span style="color: #ff0000;"> <br>border-left</span>:<span style="color: #0000ff;"> 50px solid transparent</span>;<span style="color: #ff0000;"> <br>border-right</span>:<span style="color: #0000ff;"> 50px solid transparent</span>;<span style="color: #ff0000;"> <br>height</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>width</span>:<span style="color: #0000ff;"> 100px</span>; }

15、Parallelogram

 

<span style="color: #800000;">#parallelogram </span>{<span style="color: #ff0000;"> <br>width</span>:<span style="color: #0000ff;"> 150px</span>;<span style="color: #ff0000;"> <br>height</span>:<span style="color: #0000ff;"> 100px</span>;<span style="color: #ff0000;"> <br>-webkit-transform</span>:<span style="color: #0000ff;"> skew(20deg)</span>;<span style="color: #ff0000;"> <br>-moz-transform</span>:<span style="color: #0000ff;"> skew(20deg)</span>;<span style="color: #ff0000;"> <br>-o-transform</span>:<span style="color: #0000ff;"> skew(20deg)</span>;<span style="color: #ff0000;"> <br>background</span>:<span style="color: #0000ff;"> red</span>; }

16、Star (6-points)

 

<span style="color: #800000;">#star-six </span>{<span style="color: #ff0000;"> <br>width</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>height</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>border-left</span>:<span style="color: #0000ff;"> 50px solid transparent</span>;<span style="color: #ff0000;"> <br>border-right</span>:<span style="color: #0000ff;"> 50px solid transparent</span>;<span style="color: #ff0000;"> <br>border-bottom</span>:<span style="color: #0000ff;"> 100px solid red</span>;<span style="color: #ff0000;"> <br>position</span>:<span style="color: #0000ff;"> relative</span>; }<span style="color: #800000;"> <br>#star-six:after </span>{<span style="color: #ff0000;"> <br>width</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>height</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> <br>border-left</span>:<span style="color: #0000ff;"> 50px solid transparent</span>;<span style="color: #ff0000;"> <br>border-right</span>:<span style="color: #0000ff;"> 50px solid transparent</span>;<span style="color: #ff0000;"> <br>border-top</span>:<span style="color: #0000ff;"> 100px solid red</span>;<span style="color: #ff0000;"> <br>position</span>:<span style="color: #0000ff;"> absolute</span>;<span style="color: #ff0000;"> <br>content</span>:<span style="color: #0000ff;"> ""</span>;<span style="color: #ff0000;"> <br>top</span>:<span style="color: #0000ff;"> 30px</span>;<span style="color: #ff0000;"> <br>left</span>:<span style="color: #0000ff;"> -50px</span>; }

17、Star (5-points)

 

<span style="color: #800000;">#star-five </span>{<span style="color: #ff0000;">
 margin</span>:<span style="color: #0000ff;"> 50px 0</span>;<span style="color: #ff0000;"> 
position</span>:<span style="color: #0000ff;"> relative</span>;<span style="color: #ff0000;"> 
display</span>:<span style="color: #0000ff;"> block</span>;<span style="color: #ff0000;"> 
color</span>:<span style="color: #0000ff;"> red</span>;<span style="color: #ff0000;"> 
width</span>:<span style="color: #0000ff;"> 0px</span>;<span style="color: #ff0000;"> 
height</span>:<span style="color: #0000ff;"> 0px</span>;<span style="color: #ff0000;"> 
border-right</span>:<span style="color: #0000ff;"> 100px solid transparent</span>;<span style="color: #ff0000;"> 
border-bottom</span>:<span style="color: #0000ff;"> 70px solid red</span>;<span style="color: #ff0000;"> 
border-left</span>:<span style="color: #0000ff;"> 100px solid transparent</span>;<span style="color: #ff0000;">
 -moz-transform</span>:<span style="color: #0000ff;"> rotate(35deg)</span>;<span style="color: #ff0000;"> 
-webkit-transform</span>:<span style="color: #0000ff;"> rotate(35deg)</span>;<span style="color: #ff0000;">
 -ms-transform</span>:<span style="color: #0000ff;"> rotate(35deg)</span>;<span style="color: #ff0000;">
 -o-transform</span>:<span style="color: #0000ff;"> rotate(35deg)</span>; }<span style="color: #800000;">
 #star-five:before </span>{<span style="color: #ff0000;"> 
border-bottom</span>:<span style="color: #0000ff;"> 80px solid red</span>;<span style="color: #ff0000;"> 
border-left</span>:<span style="color: #0000ff;"> 30px solid transparent</span>;<span style="color: #ff0000;"> 
border-right</span>:<span style="color: #0000ff;"> 30px solid transparent</span>;<span style="color: #ff0000;"> 
position</span>:<span style="color: #0000ff;"> absolute</span>;<span style="color: #ff0000;"> 
height</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;">
 width</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;">
 top</span>:<span style="color: #0000ff;"> -45px</span>;<span style="color: #ff0000;"> 
left</span>:<span style="color: #0000ff;"> -65px</span>;<span style="color: #ff0000;"> 
display</span>:<span style="color: #0000ff;"> block</span>;<span style="color: #ff0000;">
 content</span>:<span style="color: #0000ff;"> ''</span>;<span style="color: #ff0000;"> 
-webkit-transform</span>:<span style="color: #0000ff;"> rotate(-35deg)</span>;<span style="color: #ff0000;"> 
-moz-transform</span>:<span style="color: #0000ff;"> rotate(-35deg)</span>;<span style="color: #ff0000;"> -
ms-transform</span>:<span style="color: #0000ff;"> rotate(-35deg)</span>;<span style="color: #ff0000;"> 
-o-transform</span>:<span style="color: #0000ff;"> rotate(-35deg)</span>; }<span style="color: #800000;">
 #star-five:after </span>{<span style="color: #ff0000;"> 
position</span>:<span style="color: #0000ff;"> absolute</span>;<span style="color: #ff0000;"> 
display</span>:<span style="color: #0000ff;"> block</span>;<span style="color: #ff0000;">
 color</span>:<span style="color: #0000ff;"> red</span>;<span style="color: #ff0000;"> 
top</span>:<span style="color: #0000ff;"> 3px</span>;<span style="color: #ff0000;"> 
left</span>:<span style="color: #0000ff;"> -105px</span>;<span style="color: #ff0000;"> 
width</span>:<span style="color: #0000ff;"> 0px</span>;<span style="color: #ff0000;"> 
height</span>:<span style="color: #0000ff;"> 0px</span>;<span style="color: #ff0000;">
 border-right</span>:<span style="color: #0000ff;"> 100px solid transparent</span>;<span style="color: #ff0000;">
 border-bottom</span>:<span style="color: #0000ff;"> 70px solid red</span>;<span style="color: #ff0000;"> 
border-left</span>:<span style="color: #0000ff;"> 100px solid transparent</span>;<span style="color: #ff0000;">
 -webkit-transform</span>:<span style="color: #0000ff;"> rotate(-70deg)</span>;<span style="color: #ff0000;">
 -moz-transform</span>:<span style="color: #0000ff;"> rotate(-70deg)</span>;<span style="color: #ff0000;"> 
-ms-transform</span>:<span style="color: #0000ff;"> rotate(-70deg)</span>;<span style="color: #ff0000;"> 
-o-transform</span>:<span style="color: #0000ff;"> rotate(-70deg)</span>;<span style="color: #ff0000;"> 
content</span>:<span style="color: #0000ff;"> ''</span>; }

18、Pentagon

 

<span style="color: #800000;">#pentagon </span>{<span style="color: #ff0000;"> 
position</span>:<span style="color: #0000ff;"> relative</span>;<span style="color: #ff0000;"> 
width</span>:<span style="color: #0000ff;"> 54px</span>;<span style="color: #ff0000;"> 
border-width</span>:<span style="color: #0000ff;"> 50px 18px 0</span>;<span style="color: #ff0000;"> 
border-style</span>:<span style="color: #0000ff;"> solid</span>;<span style="color: #ff0000;"> 
border-color</span>:<span style="color: #0000ff;"> red transparent</span>; }<span style="color: #800000;"> 
#pentagon:before </span>{<span style="color: #ff0000;"> content</span>:<span style="color: #0000ff;"> ""</span>;<span style="color: #ff0000;"> 
position</span>:<span style="color: #0000ff;"> absolute</span>;<span style="color: #ff0000;"> 
height</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;">
 width</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;">
 top</span>:<span style="color: #0000ff;"> -85px</span>;<span style="color: #ff0000;">
 left</span>:<span style="color: #0000ff;"> -18px</span>;<span style="color: #ff0000;">
 border-width</span>:<span style="color: #0000ff;"> 0 45px 35px</span>;<span style="color: #ff0000;"> 
border-style</span>:<span style="color: #0000ff;"> solid</span>;<span style="color: #ff0000;"> 
border-color</span>:<span style="color: #0000ff;"> transparent transparent red</span>; }

 

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn