使用 CSS 更改按鈕的背景色


若要更改按鈕的背景色,請使用 background-color 屬性。

您可以嘗試執行以下程式碼來更改按鈕的背景色

示例

現場演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         .btn {
            background-color: yellow;
            color: black;
            text-align: center;
            font-size: 13px;
         }
      </style>
   </head>
   <body>
      <h2>Result</h2>
      <p>Click below for result:</p>
      <button class = "btn">Result</button>
   </body>
</html>

更新於: 2020 年 6 月 24 日

2K+ 次瀏覽

開啟你的 職業生涯

完成課程獲得認證

開始
廣告