css3按钮:CSS3 按钮 2024-04-16 02:38:18 0 0 创建 CSS3 按钮可以通过组合样式属性和伪类来实现<!DOCTYPE html><html><head> <link rel="stylesheet" type="text/css" href="styles.css"></head><body> <button class="basic-button">基本按钮</button></body></html> CSS (styles.css):/* 基本按钮样式 */.basic-button { display: inline-block; padding: 10px 20px; font-size: 16px; background-color: #3498db; color: #fff; border: none; border-radius: 4px; cursor: pointer; transition: background-color 0.3s ease;}/* 悬停效果 */.basic-button:hover { background-color: #2980b9;} 创建了一个基本的按钮样式,然后使用 :hover 伪类来定义鼠标悬停时的效果。主要的样式属性包括:padding:指定按钮的内边距,增加按钮的大小和点击区域。font-size:设置按钮文本的字体大小。background-color:按钮的背景颜色。color:按钮文本的颜色。border:按钮的边框样式。border-radius:圆角边框,使按钮更加美观。cursor:当鼠标悬停在按钮上时,指定光标形状。transition:定义过渡效果,实现悬停时背景颜色平滑变化。 收藏(0)