用 CSS 設定獲取焦點的元素的樣式


為了選擇有焦點的元素,使用:focus 選擇器。你可以嘗試執行以下程式碼來實現:focus 選擇器 −

示例

<!DOCTYPE html>
<html>
   <head>
      <style>
         input:focus {
            background-color: green;
         }
      </style>
   </head>
   <body>
      <form action = "">
         Subject <input type = "text" name = "subject"><br>
         Student: <input type = "text" name = "student"><br>
         Age: <input type = "number" name" = age><br>
         <input type = "submit" value="Submit">
      </form>
   </body>
</html>

更新時間: 30-6 月-2020

86 檢視

開啟你的 職業生涯

完成課程取得認證

開始
廣告