日期:2014-05-17  浏览次数:20599 次

CSS3绘图实战-Nut团队标志

css每一代都会有革命性的更新,尽管目前还有一部分浏览器没有支持CSS3,就算支持也是部分支持。但是她那强大的能力依然还是让我兴奋,一些早期不敢想象的东西,如今都可以用CSS来实现,比如,变型,渐变,动画等等。

这次我就拿CSS3的一些新功能来画出我们Nut前端团队的标志,实物如下图:



版权所有,NUT团队,如有雷同,算我们倒霉!

不说废话,直接开始。这个logo整体来说可以分为几个色块,几个不规则的形状体拼接而成。但是CSS不是HTML5,不是canvs也不是SVG,他是无法实现复杂路径绘图的,但是CSS有他独特的绘图方式,border-rasius,transform,z-index,overflow。

说白了就是通过各种圆角,变形旋转,互相遮盖,互相切割来完成。

首先是Nut的果蒂部分,这里的结构如下

1.<div class="top">
2.  <div class="right color3"></div>
3.  <div class="left color1"></div>
4.  <div class="mask1"></div>
5.  <div class="mask2"></div>
6.</div>
运行代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.justep.com/workflow.html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
*{
margin:0;
padding:0;
}
body {
background: #fff;
}
.color1{
background: #ffb400;
}
.color2{
background: #e78500;
}
.color3{
background: #bd5d00;
}
.color4{
background: #9e3300;
}
.color5{
background: #772400;
}
div{
overflow: hidden;
}
.wrapper{
width:450px;
height:450px;
left:50%;
top:50%;
margin:-225px 0 0 -225px;
position: absolute;
}
.top{
width:48px;
height:62px;
top:9px;
left:232px;
position: absolute;
}
.top .right{
width:48px;
height:62px;
border-radius: 35px 40px 0px 0px/15px 70px 10px 0px;
z-index: 1;
position: absolute;
}
.top .left{
width:160px;
height:320px;
top:7px;
left:-93px;
z-index: 2;
border-radius: 160px/320px;
position: absolute;
}
.top .mask1{
width:40px;
height:100px;
border-radius: 40px/100px;
background: #fff;
z-index: 3;
top:0px;
left:-32px;
position: absolute;
}
.top .mask2{
width:200px;
height:200px;
border-radius: 200px;
background: #fff;
z-index: 4;
top:55px;
left:-92px;
position: absolute;
}
.center{
width:340px;
height:192px;
margin:79px 0 0 57px;
}
.center .box1{
width:360px;
height:360px;
border-radius:180px;
margin:0 0 0 -20px;
}
.center .box1 .box1_1{
width:300px;
height:400px;
border-radius: 200px/300px;
margin:-40px 0 0 -20px;
}
.center .box2{
width:900px;
height:900px;
background: #fff;
margin:-265px 0 0 -383px;
border-radius: 900px;
}
.bottom{
width:550px;
height:330px;
border-radius: 550px/330px;
margin:-75px 0 0 -122px;
transform: rotate(6deg);
-webkit-transform: rotate(6deg);
-moz-transform: rotate(6deg);
-o-transform: rotate(6deg); /*Opera*/
}
.bottom .box1{
width:320px;
height:600px;
border-radius: 320px/600px;
margin:-380px 0 0 180px;
transform: rotate(5deg);
-webkit-transform: rotate(5deg);
-moz-transform: rotate(5deg);
-o-transform: rotate(5deg); /*Opera*/
}
.bottom .box2{
width:320px;
height:600px;
border-radius: 320px/600px;
margin:35px 0 0 -35px;
transform: rotate(3deg);
-webkit-transform: rotate(3deg);
-moz-transform: rotate(3deg);
-o-transform: rotate(3deg); /*Opera*/
}
.bottom .box3{
width:320px;
height:600px;
border-radius: 320px/600px;
margin:30px 0 0 -30px;
}
</style>
</head>
<body&g