如何使用 CSS 在 HTML 中创建不同形状






4.60/5 (9投票s)
让我们使用强大而令人惊叹的 CSS 在 HTML 中创建不同类型的形状。
引言
大家好,让我们学习如何使用简单的 CSS 创建各种酷炫的形状,而无需使用图片。
使用代码
矩形
.rectangle {
width: 250px;
height: 150px;
background-color: #6DC75F;
}
<div class="rectangle"></div>
三角形
.triangleUp {
border-left: 75px solid transparent;
border-right: 75px solid transparent;
border-bottom: 150px solid #6DC75F;
width: 0;
height: 0;
}
<div class="triangleUp"></div>
椭圆
.oval {
width: 300px;
height: 150px;
background: #6DC75F;
-moz-border-radius: 150px / 75px;
-webkit-border-radius: 150px / 75px;
border-radius: 150px / 75px;
}
<div class="oval"></div>
神奇的月亮
.moon {
width: 150px;
height: 150px;
border-radius: 50%;
box-shadow: 15px 15px 0 0 green;
}
<div class="moon"></div>
叶子
.leaf {
border-radius: 5px 300px 3px 300px;
background: #6DC75F;
width: 150px;
height: 150px;
}
<div class="leaf"></div>
关注点
使用 CSS 你可以做很多神奇的事情...
编码愉快.....