button {
border: none; /* 取消默认边框 */
background: none; /* 取消默认背景 */
color: inherit; /* 继承父元素的文本颜色 */
padding: 0; /* 取消内边距 */
margin: 0; /* 取消外边距 */
box-shadow: none; /* 取消阴影 */
font: inherit; /* 继承字体样式 */
cursor: pointer; /* 鼠标悬停时手型 */
}
在书写CSS的时候,确保将这些样式写入button的选择器中,以便于在不同浏览器中的一致性。针对不同设计需求,可以灵活调整样式。
button {
border: 1px solid #007BFF; /* 自定义边框 */
background-color: #007BFF; /* 自定义背景色 */
color: #FFFFFF; /* 自定义文字颜色 */
padding: 10px 20px; /* 自定义内边距 */
border-radius: 5px; /* 自定义圆角 */
font-size: 16px; /* 自定义字体大小 */
transition: background 0.3s; /* 添加平滑过渡效果 */
}
button:hover {
background-color: #0056b3; /* 悬停效果 */
}
button:hover {
background-color: #0056b3; /* 悬停状态样式 */
}
button:active {
transform: scale(0.95); /* 点击状态效果 */
}
button:focus {
outline: none; /* 取消默认聚焦边框 */
}