在css中,可以利用“background-color”屬性來設置按鈕背景色,該屬性的作用就是設置元素的背景顏色,只需要給按鈕元素添加“background-color:顏色值;”樣式即可。
本教程操作環境:windows7系統、CSS3&&HTML5版、Dell G3電腦。
css怎樣設置按鈕背景色
在css中,可以利用background-color屬性來設置按鈕的背景色,background-color 屬性用于設置元素的背景顏色。
下面我們就通過示例來看一下具體操作,示例如下:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style> button{ outline: 0; } .el-button { padding: 0 24px; border: 1px solid #1E9FFF; font-size: 14px; color: #1E9FFF; line-height: 26px; border-radius: 4px; cursor: pointer; } </style> </head> <body> <button type="button" class="el-button"><span>按鈕</span></button> </body> </html>
輸出結果:
此時按鈕的背景顏色是灰色的,下面我們只需要給按鈕元素添加“background-color:顏色值;”樣式就可以設置按鈕的背景色。
示例如下:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style> button{ outline: 0; } .el-button { padding: 0 24px; border: 1px solid #1E9FFF; font-size: 14px; color: #1E9FFF; line-height: 26px; border-radius: 4px; cursor: pointer; background-color:#ffffff; } </style> </head> <body> <button type="button" class="el-button"><span>按鈕</span></button> </body> </html>
輸出結果:
此時按鈕背景色為白色。
(學習視頻分享:css視頻教程)