css图形设计代码,CSS图形绘制练习-最常见的40种形状和图形源码分享

包括圆形,椭圆形,三角形,倒三角形,左三角形,右三角形,菱形,梯形,长方形,正方形,圆环,平行四边形,五角星,六角星,五边形,六边形,八边形,心形,蛋形,无穷符号,消息提示框,钻石,八卦图,食豆人,扇形,月牙,顶左直角三角形,顶右直角三角形 ,底左直角三角形 ,底右直角三角形 ,八角形, 十二角形……

Square(正方形)

9c33a72acbd80fdca539e7ad74700b38.png

#square {

width: 100px;

height: 100px;

background: red;

}

Rectangle(矩形)

9c33a72acbd80fdca539e7ad74700b38.png

#rectangle {

width: 200px;

height: 100px;

background: red;

}

Circle(圆形)

9c33a72acbd80fdca539e7ad74700b38.png

#circle {

width: 100px;

height: 100px;

background: red;

-moz-border-radius: 50px;

-webkit-border-radius: 50px;

border-radius: 50px;

}

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

Oval(椭圆形)

9c33a72acbd80fdca539e7ad74700b38.png

#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(向上的三角形)

9c33a72acbd80fdca539e7ad74700b38.png

#triangle-up {

width: 0;

height: 0;

border-left: 50px solid transparent;

border-right: 50px solid transparent;

border-bottom: 100px solid red;

}

Triangle Down(向下)

9c33a72acbd80fdca539e7ad74700b38.png

#triangle-down {

width: 0;

height: 0;

border-left: 50px solid transparent;

border-right: 50px solid transparent;

border-top: 100px solid red;

}

Triangle Left(向左)

9c33a72acbd80fdca539e7ad74700b38.png

#triangle-left {

width: 0;

height: 0;

border-top: 50px solid transparent;

border-right: 100px solid red;

border-bottom: 50px solid transparent;

}

Triangle Right(向右)

9c33a72acbd80fdca539e7ad74700b38.png

#triangle-right {

width: 0;

height: 0;

border-top: 50px solid transparent;

border-left: 100px solid red;

border-bottom: 50px solid transparent;

}

Triangle Top Left(左上)

9c33a72acbd80fdca539e7ad74700b38.png

#triangle-topleft {

width: 0;

height: 0;

border-top: 100px solid red;

border-right: 100px solid transparent;

}

Triangle Top Right(右上)

9c33a72acbd80fdca539e7ad74700b38.png

#triangle-topright {

width: 0;

height: 0;

border-top: 100px solid red;

border-left: 100px solid transparent;

}

Triangle Bottom Left(左下)

9c33a72acbd80fdca539e7ad74700b38.png

#triangle-bottomleft {

width: 0;

height: 0;

border-bottom: 100px solid red;

border-right: 100px solid transparent;

}

Triangle Bottom Right(右下)

9c33a72acbd80fdca539e7ad74700b38.png

#triangle-bottomright {

width: 0;

height: 0;

border-bottom: 100px solid red;

border-left: 100px solid transparent;

}

Curved Tail Arrow(弯尾箭头)

9c33a72acbd80fdca539e7ad74700b38.png

9c33a72acbd80fdca539e7ad74700b38.png

#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(梯形)

9c33a72acbd80fdca539e7ad74700b38.png

#trapezoid {

border-bottom: 100px solid red;

border-left: 50px solid transparent;

border-right: 50px solid transparent;

height: 0;

width: 100px;

}

Parallelogram(平行四边形)

9c33a72acbd80fdca539e7ad74700b38.png

#parallelogram {

width: 150px;

height: 100px;

-webkit-transform: skew(20deg);

-moz-transform: skew(20deg);

-o-transform: skew(20deg);

background: red;

}

Star (6-points)(六角星)

9c33a72acbd80fdca539e7ad74700b38.png

#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)(五角星)

9c33a72acbd80fdca539e7ad74700b38.png

#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(五边形)

9c33a72acbd80fdca539e7ad74700b38.png

#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(六边形)

9c33a72acbd80fdca539e7ad74700b38.png

#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(八边形)

9c33a72acbd80fdca539e7ad74700b38.png

#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;

}

125jz网原创文章。发布者:江山如画,转载请注明出处:http://www.125jz.com/4976.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值