1 设计图形
- 设计菱形
利用旋转rotate
属性,正方形旋转45°即得菱形,但要保证原本图形为正方形
<body>
<style type="text/css">
#box{
margin: 100px;
width: 150px;
height: 150px;
background: #93FB40;
box-shadow: 2px 2px 2px #999;
transform: rotate(45deg);
}
</style>
<div id="box"></div>
</body>
- 设计平行四边形
利用倾斜skew
属性,X轴或Y轴旋转一定角度,要保证原本图形为矩形
<body>
<style type="text/css">
#box{
margin: 100px;
width: 150px;
height: 150px;
background: #93FB40;
box-shadow: 2px 2px 2px #999;
transform: skewX(30deg);
}
</style>
<div id="box"></div>
</body>
- 设计三角形
将不需要方向的border属性设置为透明(transparent)
<style type="text/css">
#box{
width: 0px;
height: 0px;
border-left: 100px solid transparent;
border-top: 100px solid transparent;
border-right: 100px solid transparent;
border-bottom: 100px solid red;
}
</style>
<div id="box"></div>