以下是在CSS中绘制常见图形的示例代码:
- 线条:
css
.line {
width: 100px;
height: 1px;
background-color: black;
}
- 箭头:
css
.arrow {
width: 0;
height: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-right: 10px solid black;
}
- 三角形:
css
.triangle {
width: 0;
height: 0;
border-top: 50px solid transparent;
border-left: 50px solid black;
border-bottom: 50px solid transparent;
}
- 矩形:
css
.rectangle {
width: 100px;
height: 50px;
background-color: black;
}
- 圆:
css
.circle {
width: 50px;
height: 50px;
border-radius: 50%;
background-color: black;
}
- 椭圆:
css
.ellipse {
width: 100px;
height: 50px;
border-radius: 50%;
background-color: black;
}
- 平行四边形:
css
.parallelogram {
width: 100px;
height: 50px;
transform: skewX(20deg);
background-color: black;
}
- 菱形:
css
.rhombus {
width: 0;
height: 0;
border: 50px solid black;
border-right-color: transparent;
border-left-color: transparent;
transform: rotate(45deg);
}
- 梯形:
css
.trapezoid {
width: 100px;
height: 0;
border-top: 50px solid black;
border-left: 25px solid transparent;
border-right: 25px solid transparent;
}