HTML5中国

 找回密码
 立即注册

QQ登录

只需一步,快速开始

HTML5中国 首页 教程视频 查看内容

史上最强大的40多个纯CSS绘制的图形(上)

2016-10-10 08:55| 发布者: Hyukoh| 查看: 1512| 评论: 0|原作者: 陈少华|来自: 码农网

摘要: 里面有最简单的矩形、圆形和三角形,也有各种常见的多边形,甚至是阴阳太极和网站小图标

  Square(正方形)


#square {

  width: 100px;

  height: 100px;

  background: red;

  }

  Rectangle(矩形)


  #rectangle {

  width: 200px;

  height: 100px;

  background: red;

  }


  Circle(圆形)

 

 #circle {

  width: 100px;

  height: 100px;

  background: red;

  -moz-border-radius: 50px;

  -webkit-border-radius: 50px;

  border-radius: 50px;

  }

  /* 可以使用百分比值(大于50%),但是低版本的Android不支持 */

  Oval(椭圆形)

  

#oval {

  width: 200px;

  height: 100px;

  background: red;

  -moz-border-radius: 100px / 50px;

  -webkit-border-radius: 100px / 50px;

  border-radius: 100px / 50px;

  }

  /* 可以使用百分比值(大于50%),但是低版本的Android不支持 */

  Triangle Up(向上的三角形)

 

 #triangle-up {

  width: 0;

  height: 0;

  border-left: 50px solid transparent;

  border-right: 50px solid transparent;

  border-bottom: 100px solid red;

  }

  Triangle Down(向下)

  

#triangle-down {

  width: 0;

  height: 0;

  border-left: 50px solid transparent;

  border-right: 50px solid transparent;

  border-top: 100px solid red;

  }

  Triangle Left(向左)

 

 #triangle-left {

  width: 0;

  height: 0;

  border-top: 50px solid transparent;

  border-right: 100px solid red;

  border-bottom: 50px solid transparent;

  }

  Triangle Right(向右)

 

 #triangle-right {

  width: 0;

  height: 0;

  border-top: 50px solid transparent;

  border-left: 100px solid red;

  border-bottom: 50px solid transparent;

  }

  Triangle Top Left(左上)

 

 #triangle-topleft {

  width: 0;

  height: 0;

  border-top: 100px solid red;

  border-right: 100px solid transparent;

  }

  Triangle Top Right(右上)

  

#triangle-topright {

  width: 0;

  height: 0;

  border-top: 100px solid red;

  border-left: 100px solid transparent;

  }

  Triangle Bottom Left(左下)

  

#triangle-bottomleft {

  width: 0;

  height: 0;

  border-bottom: 100px solid red;

  border-right: 100px solid transparent;

  }

  Triangle Bottom Right(右下)

  

#triangle-bottomright {

  width: 0;

  height: 0;

  border-bottom: 100px solid red;

  border-left: 100px solid transparent;

  }

  Curved Tail Arrow(弯尾箭头)

 

 #curvedarrow {

  position: relative;

  width: 0;

  height: 0;

  border-top: 9px solid transparent;

  border-right: 9px solid red;

  -webkit-transform: rotate(10deg);

  -moz-transform: rotate(10deg);

  -ms-transform: rotate(10deg);

  -o-transform: rotate(10deg);

  }

  #curvedarrow:after {

  content: "";

  position: absolute;

  border: 0 solid transparent;

  border-top: 3px solid red;

  border-radius: 20px 0 0 0;

  top: -12px;

  left: -9px;

  width: 12px;

  height: 12px;

  -webkit-transform: rotate(45deg);

  -moz-transform: rotate(45deg);

  -ms-transform: rotate(45deg);

  -o-transform: rotate(45deg);

  }

  Trapezoid(梯形)

  #trapezoid {

  border-bottom: 100px solid red;

  border-left: 50px solid transparent;

  border-right: 50px solid transparent;

  height: 0;

  width: 100px;

  }


  Parallelogram(平行四边形)

 

 #parallelogram {

  width: 150px;

  height: 100px;

  -webkit-transform: skew(20deg);

  -moz-transform: skew(20deg);

  -o-transform: skew(20deg);

  background: red;

  }

  Star (6-points)(六角星)

  

#star-six {

  width: 0;

  height: 0;

  border-left: 50px solid transparent;

  border-right: 50px solid transparent;

  border-bottom: 100px solid red;

  position: relative;

  }

  #star-six:after {

  width: 0;

  height: 0;

  border-left: 50px solid transparent;

  border-right: 50px solid transparent;

  border-top: 100px solid red;

  position: absolute;

  content: "";

  top: 30px;

  left: -50px;

  }

  Star (5-points)(五角星)

  

#star-five {

  margin: 50px 0;

  position: relative;

  display: block;

  color: red;

  width: 0px;

  height: 0px;

  border-right: 100px solid transparent;

  border-bottom: 70px solid red;

  border-left: 100px solid transparent;

  -moz-transform: rotate(35deg);

  -webkit-transform: rotate(35deg);

  -ms-transform: rotate(35deg);

  -o-transform: rotate(35deg);

  }

  #star-five:before {

  border-bottom: 80px solid red;

  border-left: 30px solid transparent;

  border-right: 30px solid transparent;

  position: absolute;

  height: 0;

  width: 0;

  top: -45px;

  left: -65px;

  display: block;

  content: '';

  -webkit-transform: rotate(-35deg);

  -moz-transform: rotate(-35deg);

  -ms-transform: rotate(-35deg);

  -o-transform: rotate(-35deg);

  }

  #star-five:after {

  position: absolute;

  display: block;

  color: red;

  top: 3px;

  left: -105px;

  width: 0px;

  height: 0px;

  border-right: 100px solid transparent;

  border-bottom: 70px solid red;

  border-left: 100px solid transparent;

  -webkit-transform: rotate(-70deg);

  -moz-transform: rotate(-70deg);

  -ms-transform: rotate(-70deg);

  -o-transform: rotate(-70deg);

  content: '';

  }

  Pentagon(五边形)

  

#pentagon {

  position: relative;

  width: 54px;

  border-width: 50px 18px 0;

  border-style: solid;

  border-color: red transparent;

  }

  #pentagon:before {

  content: "";

  position: absolute;

  height: 0;

  width: 0;

  top: -85px;

  left: -18px;

  border-width: 0 45px 35px;

  border-style: solid;

  border-color: transparent transparent red;

  }

  Hexagon(六边形)

 

 #hexagon {

  width: 100px;

  height: 55px;

  background: red;

  position: relative;

  }

  #hexagon:before {

  content: "";

  position: absolute;

  top: -25px;

  left: 0;

  width: 0;

  height: 0;

  border-left: 50px solid transparent;

  border-right: 50px solid transparent;

  border-bottom: 25px solid red;

  }

  #hexagon:after {

  content: "";

  position: absolute;

  bottom: -25px;

  left: 0;

  width: 0;

  height: 0;

  border-left: 50px solid transparent;

  border-right: 50px solid transparent;

  border-top: 25px solid red;

  }

  Octagon(八边形)

  

#octagon {

  width: 100px;

  height: 100px;

  background: red;

  position: relative;

  }

  #octagon:before {

  content: "";

  position: absolute;

  top: 0;

  left: 0;

  border-bottom: 29px solid red;

  border-left: 29px solid #fff;

  border-right: 29px solid #fff;

  width: 42px;

  height: 0;

  }

  #octagon:after {

  content: "";

  position: absolute;

  bottom: 0;

  left: 0;

  border-top: 29px solid red;

  border-left: 29px solid #fff;

  border-right: 29px solid #fff;

  width: 42px;

  height: 0;

  }

  Heart(心形)

  

#heart {

  position: relative;

  width: 100px;

  height: 90px;

  }

  #heart:before,

  #heart:after {

  position: absolute;

  content: "";

  left: 50px;

  top: 0;

  width: 50px;

  height: 80px;

  background: red;

  -moz-border-radius: 50px 50px 0 0;

  border-radius: 50px 50px 0 0;

  -webkit-transform: rotate(-45deg);

  -moz-transform: rotate(-45deg);

  -ms-transform: rotate(-45deg);

  -o-transform: rotate(-45deg);

  transform: rotate(-45deg);

  -webkit-transform-origin: 0 100%;

  -moz-transform-origin: 0 100%;

  -ms-transform-origin: 0 100%;

  -o-transform-origin: 0 100%;

  transform-origin: 0 100%;

  }

  #heart:after {

  left: 0;

  -webkit-transform: rotate(45deg);

  -moz-transform: rotate(45deg);

  -ms-transform: rotate(45deg);

  -o-transform: rotate(45deg);

  transform: rotate(45deg);

  -webkit-transform-origin: 100% 100%;

  -moz-transform-origin: 100% 100%;

  -ms-transform-origin: 100% 100%;

  -o-transform-origin: 100% 100%;

  transform-origin :100% 100%;

  }

  Infinity(无限符图形)

  

#infinity {

  position: relative;

  width: 212px;

  height: 100px;

  }

  #infinity:before,

  #infinity:after {

  content: "";

  position: absolute;

  top: 0;

  left: 0;

  width: 60px;

  height: 60px;

  border: 20px solid red;

  -moz-border-radius: 50px 50px 0 50px;

  border-radius: 50px 50px 0 50px;

  -webkit-transform: rotate(-45deg);

  -moz-transform: rotate(-45deg);

  -ms-transform: rotate(-45deg);

  -o-transform: rotate(-45deg);

  transform: rotate(-45deg);

  }

  #infinity:after {

  left: auto;

  right: 0;

  -moz-border-radius: 50px 50px 50px 0;

  border-radius: 50px 50px 50px 0;

  -webkit-transform: rotate(45deg);

  -moz-transform: rotate(45deg);

  -ms-transform: rotate(45deg);

  -o-transform: rotate(45deg);

  transform: rotate(45deg);

  }

  Diamond Square(菱形)


#diamond {

  width: 0;

  height: 0;

  border: 50px solid transparent;

  border-bottom-color: red;

  position: relative;

  top: -50px;

  }

  #diamond:after {

  content: '';

  position: absolute;

  left: -50px;

  top: 50px;

  width: 0;

  height: 0;

  border: 50px solid transparent;

  border-top-color: red;

  }

  Diamond Shield(钻石盾牌)

 

 #diamond-shield {

  width: 0;

  height: 0;

  border: 50px solid transparent;

  border-bottom: 20px solid red;

  position: relative;

  top: -50px;

  }

  #diamond-shield:after {

  content: '';

  position: absolute;

  left: -50px; top: 20px;

  width: 0;

  height: 0;

  border: 50px solid transparent;

  border-top: 70px solid red;

  }

  Diamond Narrow

  

#diamond-narrow {

  width: 0;

  height: 0;

  border: 50px solid transparent;

  border-bottom: 70px solid red;

  position: relative;

  top: -50px;

  }

  #diamond-narrow:after {

  content: '';

  position: absolute;

  left: -50px; top: 70px;

  width: 0;

  height: 0;

  border: 50px solid transparent;

  border-top: 70px solid red;

  }




来源作者: 陈少华
本站资源均由 HTML5中国 编辑从其他网站精选HTML5相关资源转载,以供网友参阅,投稿: news@html5cn.org

鲜花

握手

雷人

路过

鸡蛋

相关阅读

最新评论

HTML5中国微信

小黑屋|关于我们|HTML5论坛|友情链接|手机版|HTML5中国 ( 京ICP备11006447号 京公网安备:11010802018489号  

GMT+8, 2017-5-27 16:04

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

返回顶部