如何使用 CSS 创建不同的形状?
cssweb developmentfront end technology更新于 2025/12/8 2:52:17
要使用 CSS 创建不同的形状,代码如下 −
示例
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
div {
display: inline-block;
margin: 20px;
}
.square {
width: 100px;
height: 100px;
background: rgb(23, 153, 121);
border: 3px solid darkblue;
}
.rectangle {
width: 200px;
height: 100px;
background: rgb(255, 232, 21);
border: 3px solid rgb(42, 0, 70);
}
.circle {
width: 100px;
height: 100px;
background: rgb(0, 255, 13);
border: 3px solid rgb(27, 0, 78);
border-radius: 50%;
}
</style>
</head>
<body>
<h1>Different Shapes in CSS example</h1>
<div class="square"></div>
<div class="rectangle"></div>
<div class="circle"></div>
</body>
</html>
输出
上述代码将产生以下输出 −

相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

