CSS圆形按钮是一种使用CSS样式创建的按钮,其形状为圆形。通过设置边框半径(border-radius
)为50%,可以使一个矩形元素变成圆形。
以下是一个简单的纯CSS圆形按钮的示例代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS圆形按钮</title>
<style>
.circle-button {
display: inline-block;
width: 100px;
height: 100px;
border-radius: 50%;
background-color: #007bff;
color: white;
text-align: center;
line-height: 100px;
font-size: 16px;
cursor: pointer;
}
.circle-button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="circle-button">点击</div>
</body>
</html>
border-radius
设置为50%。background-color
属性的设置,确保没有被其他样式覆盖。:hover
伪类样式设置不当。:hover
伪类样式中设置了明显的背景颜色变化或其他视觉效果。通过以上方法,可以创建一个美观且功能齐全的CSS圆形按钮。
领取专属 10元无门槛券
手把手带您无忧上云